Basically, during ajax synchronous request, the browser is blocked and javascript cannot be executed while the browser is blocking. Because of this, jQuery cannot abort an ajax request after a set timeout, because jQuery is javascript, and javascript cannot be executed while the browser is blocking. This is the main disadvantage of synchronous ajax.
Anytime you may need a synchronous request, you should instead use asynchronous code with what should happen after the callback, as shown below:
$.ajax({ url : 'webservices.php', timeout: 200, dataType : 'json', data : { 'cmd' : 'ping', }, success : function(data, textStatus) { $.ajax({ url : 'webservices.php', async: false, dataType : 'json', data : { 'cmd' : 'feedback', 'data' : data, 'userinfo' : window.dsuser }, success : function(data, textStatus) {
source share