ajaxComplete() in jQuery

.ajaxComplete() : This jQuery mthod is used to register a handler to be called when Ajax requests completed.
Whenever an Ajax request completes, jQuery triggers the ajaxComplete event and all handlers that have been registered with the .ajaxComplete() method are executed at this time.

Syntax :

$(document).ajaxComplete( )

Example 

<html>
<head>
 <title>ajaxComplete() Example</title>
 <link href="Content/bootstrap.css" rel="stylesheet" />
 <script src="Scripts/jquery-1.9.1.js"></script>
 <script type="text/javascript" language="javascript">
 $(document).ready(function () {

 $("#btnSubmit").click(function (event) {
 $('#step1').load('Step1.html');
 });

 $(document).ajaxComplete(function (event, request, settings) {
 $("#Step2").html('ajaxComplete() request has completed.');
 });

 });
 </script>
</head>
<body style="margin:100px"> 
 <div id="step1" class="bg-danger">
 Step - 1
 </div>
 <br />
 <div id="Step2" class="bg-success">
 Step - 2
 </div>
 
 <br />
 <input type="button" class="bg-primary" id="btnSubmit" value="Submit" />

</body>
</html>

Result : When click on Submit button in step1 div has html ‘Submit button has clicked.’ ‘ Step1.html page will load in step1 div and step2 div has html that  ‘
ajaxComplete() called’.

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *