Gaetan Gaetan - 1 year ago 146
jQuery Question

jQuery Ajax request async false

I'd like to know why I get this error if I send a ajax request like:

url: "testOperation.php",
async: false,
data: compareHeure,
success: function (data, statusRequest) {


Synchronous XMLHttpRequest on the main thread is deprecated because of
its detrimental effects to the end user's experience. For more help,

Is there a problem ?


Jai Jai
Answer Source

I'd like to know why I get this error

The short answer is because of this option in the ajax:

async: false,

There could be other better solution to the problem you currently have. If you post more details about why do you need to use Synchronous ajax?

Either use this way:

       // make another ajax call here then    

You can use jQuery.when():

$.when( $.ajax("/page1.php"), $.ajax("/page2.php") ).done(function(a1, a2) {
    // here you can get both ajax response when both gets completed.

Here .done() only executed when both ajax gets completed.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download