jQuery ajax - ajaxStop() method

Example

Trigger a prompt box when all AJAX requests are completed:

$("div").ajaxStop(function(){
  alert("All AJAX requests have been completed");
});

Try It Yourself

Definition and Usage

The ajaxStop() method executes a function when the AJAX request is completed. It is an Ajax event.

Detailed Explanation

No matter when the Ajax request is completed, jQuery will check if there are any other Ajax requests. If not, jQuery will trigger the ajaxStop event. At this time, any function registered by .ajaxStop() method will be executed.

Syntax

.ajaxStop(function())
Parameters Description
function() Specify a function to be executed when the AJAX request is completed.

Example

Hide information after AJAX request is completed:

$("#loading").ajaxStop(function(){
  $(this).hide();
});