Answer the question
In order to leave comments, you need to log in
Jquery, Synchronous $.getJSON?
Good afternoon.
Can you please tell me if it is possible to execute the $.getJSON function synchronously?
$.ajaxSetup({ async: false }); Does not help
Answer the question
In order to leave comments, you need to log in
$.ajax({
url: url,
dataType: 'json',
async: false,
data: data,
success: callback
});
Somehow too lazy to think, but I think this will work:
var json = (function(data_url){
var result;
$.ajax({
async: false,
url: data_url,
dataType: 'json',
success: function®{
result = r;
}
});
return result;
})(url);
From the documentation for jQuery they write that it is not.
"
async
Default: true
… Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active.
"
api.jquery.com/jQuery .ajax/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question