AjaxStop () not working

This is the code that did not work:

$(document).ajaxStop(function() { $(this).unbind("ajaxStop"); //prevent running again when other calls finish // Display everything display(); }); 

And here is my Ajax function:

 function getAjax(url, callback) { jQuery.ajaxPrefilter(function( options ) { options.global = true; }); $.ajax({ url: url, type: "GET", dataType: "jsonp", success: callback }); } 

Why ajaxStop() never starts?

+4
source share
1 answer

You will notice that I am making JSONP requests. It took me a long time to find this, but the answer to this question can be found here .

From the ticket:

JSONP requests are not guaranteed (since errors are not caught). jQuery 1.5 forces the global parameter false in this case, so the ajax internal request counter is guaranteed to return to zero at one point or another.

If you want all requests to be dismissed from events, no matter what (and taking into account the same discrepancy 1.4.4 were set), you can use the following preliminary filter:

 jQuery.ajaxPrefilter(function( options ) { options.global = true; }); 

Example: http://jsfiddle.net/X4JTx/

+5
source

All Articles