The .ajaxStop()
method is available for this, it only fires when the last of the current ajax requests finishes. Here's the full description:
Whenever an Ajax request completes, jQuery checks whether there are any other outstanding Ajax requests. If none remain, jQuery triggers the ajaxStop
event. Any and all handlers that have been registered with the .ajaxStop()
method are executed at this time.
For example if you wanted to just run something, document is a good place to hook in:
$(document).ajaxStop(function() {
//all requests finished!, do something with all your new fancy data
});
Or you could display a message when this happens, like this:
$("#ajaxProgressDiv").ajaxStop(function() {
//display for 2 seconds then fade out
$(this).text("All done!").delay(2000).fadeOut();
});