Last Updated: February 25, 2016
·
880
· merys

Ajax Syncro

Ajax is asynchronous by definition, but sometimes you have to wait for the completion of a transaction. How?

$.ajaxSetup({ async: false });
$.post(url, {});
$.ajaxSetup({ async: true   });

Simply!!!!

2 Responses
Add your response

async: false will halt the browser, especially when using IE (it could freeze the browser until request is done)..

It's a better choice using the ajax request callbacks :-)

over 1 year ago ·

@emiliolalvarez , you're right!
Exactly:

$.ajax({
url:..,
success: function(data) {
//My function
}
});

over 1 year ago ·