.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 theajaxStopevent 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.
|
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 returningfalsewithin thebeforeSendcallback 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.
Related Tutorials
jQuery Advanced Tutorials - Lesson 11 - Ajax Global Event Handlers