I
I
iamsaint2012-02-10 09:26:33
JavaScript
iamsaint, 2012-02-10 09:26:33

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

4 answer(s)
H
himik, 2012-02-10
@himik

$.ajax({
  url: url,
  dataType: 'json',
  async: false,
  data: data,
  success: callback
});

S
Sergey, 2012-02-10
Protko @Fesor

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);

Z
Zamorozka, 2012-02-10
@Zamorozka

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/

M
MT, 2012-02-11
@MTonly

What problem do you want to solve with this?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question