.ajaxStop()S2C Home « Ajax « .ajaxStop()

Ajax global stop handler.

Description

The .ajaxStop() Ajax method, allows us to register an Ajax Event handler to be called when all Ajax requests are finished.

  • The .ajaxStop() method callbacks are executed via the ajaxStop event which is triggered when the first starts.

Syntax

Signature Description
.ajaxStop( handler() )Register an Ajax Event handler to be called when all Ajax requests are finished.

Parameters

Parameter Description Type
handler() The function to be called.
  • The callback is fired in the context of the current jQuery instance, so the this special operator refers to that instance.
Function

Return

A jQuery object.

.ajaxStop( handler() ) ExampleTop

Register an Ajax Event handler to be called when all Ajax requests are finished.

  • The .ajaxStop() method is also triggered when the last outstanding Ajax request was cancelled by returning false within the beforeSend callback function.

In the example below when we press the button the first time, we use the .ajaxStop() method to set up a global event handler to be run. The handler is fired when all Ajax requests have finsihed. In this case the handler outputs a message informing us all requests are finished.


$(function(){
  $('#btn5').one('click', function(){
    // Register global event handler and attach to 'div5' element
    $('#div5').ajaxStop(function() {
       $(this).append('Triggered the ajaxStop() global event handler.<br>');
    });
    $.get( "../js/get8.js" );
    $.post( "../js/post5.js" );
  });
});

div5. Some initial text.

Press the button below to action the above code: