In the following, the return statement is being executed before the call to $.get() finishes. How can I change this?
The callback code by @Adam Rackis is working for me. In fact, if the content of the url is of json structure, you can directly refer the fields like this. Note that aft = { yourToken :'' } is just dummy since I am not using the value in this dictionary at all. I just want to get the user_id from the URL.
var aft = { yourToken: '' };
aft.setToken = function(url, callback){
$.get(url, function(data) {
user_id = data[0]['user_id'];
if (callback)
callback(data);
});
};
aft.setToken("https://XXXXXX.azurewebsites.net/.auth/me", function(dataReturned){
alert("You user id is " + labeler);