ajaxStop() Method - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:ajaxStop

Description

The ajaxStop() method sets a function to run when AJAX requests have completed and no other requests are pending.

Syntax

Parameter Description
function() Required. Specifies the function to run when all AJAX requests have completed

The following code shows how to trigger an alert box when all AJAX requests have completed:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $(document).ajaxStop(function(){
        console.log("All AJAX requests completed");
    });/*ww  w. j  a  v  a 2s.  c o  m*/
    $("button").click(function(){
        $("div").load("demo_ajax_load.txt");
        $("div").load("demo_ajax_load.asp");
    });
});
</script>
</head>
<body>

<button>test</button>

</body>
</html>

Related Tutorials