Home >>jQuery Tutorial >jQuery ajaxComplete() Method
jQuery ajaxComplete() method in jQuery and used to specifies a function to be run when an AJAX request completes.
Syntax:$(document).ajaxComplete(function(event,xhr,options))
Parameter | Description |
---|---|
function(event,xhr,options) | It is a Required parameter and is used to specifies the function to run when the request completes. Additional parameters:
|
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(document).ajaxStart(function(){
$("#Div").css("display", "block");
});
$(document).ajaxComplete(function(){
$("#Div").css("display", "none");
});
$(".btn1").click(function(){
$("#txt1").load("demo_ajax_load.php");
});
});
</script>
</head>
<body>
<div id="txt1"><h2>Change this text</h2></div>
<button class="btn1">Click me to Change Content</button>
<div id="Div1" style="display:none;width:69px;height:89px;border:1px solid black;position:absolute;top:50%;left:50%;padding:2px;"><img src='demo_wait.gif' width="64" height="64" /><br>Loading..</div>
</body>
</html>