When I try to use the token data it acts like it is out of scope or it leaked. I have tested this in firefox and cannot figure out what is happening. If you could help me understand why it fails to return the token please feel free to reply.
the code that retreives 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);
}
});
request.fail(function(jqXHR, textStatus) {
alert("Error: "+textStatus);
});
alert($(document.body).data("token"));
});
An example resultset from the server:{"statusCode": 1, "response": "1fa8997a0cb5062144b25c1ff917a5f293bee88b62cd4f99aca26fda12515372" }