The script below gets the json result I have provided at the bottom of this post. Once the token has been retrieved it will be stored via the data() method. Though for some reason the token is not being passed beyond the ajax() call for some reason. I was wondering if you see a mistake in my code or with the json result below where the code is not passing the token not to other methods below the ajax() call that retrieves the token from the auth server?

Here is the javascript that retrieves the token:
    $(function() {
    var request = $.ajax({
    type: "GET",
    cache: false,
    data: {v: 1, r: 'requestToken', apikey: 'root', secret: 'root'},
    url: "/vdesktop/deskapi/",
    dataType: "json",
    request.done(function(data) {
    if (data.statusCode == 1) {
    $token = data.response;
    $(document.body).data("token", data.response);
    } else{
    alert("Error: ("+data.statusCode+") "+data.response);
    });, textStatus) {
    alert("Error: "+textStatus);
here is a json result from the auth server (so you can test if you want):
{"statusCode": 1, "response": "1fa8997a0cb5062144b25c1ff917a5f293bee88b62cd4f99aca26fda12515372" }