I want to get the value returned by ajax call in variable x
without making the ajax call synchronus. How can I achieve this?
foo = function() {
var x = foo1();
// var x is always undefined
}
foo1 = function() {
var deferred = foo2();
deferred.then(function(response) { return response; });
}
foo2 = function() {
return dojo.xhrGet(); // ajax call
}