I have the following problem: there is no way to turn off asyncronous mode in $.ajax when using jsonp (http://api.jquery.com/jQuery.ajax/, async section). So the code
module = (function($)
{
var result = null;
var request = function(inputData)
{
$.ajax({
url: "http://some.site",
type: "post",
data: inputData,
dataType: "jsonp",
success: function(response)
{
result = response;
}
});
return result;
}
})($);
console.log(module.request());
will result in "null" on the first call, and in actual data on the second one. So how can I make javascript wait for ajax to complete request and only after that return the result?