Home >>jQuery Tutorial >jQuery ajaxStart() Method

jQuery ajaxStart() Method

jQuery ajaxStart() Method

jQuery ajaxStart() method in jQuery is used to specifies a function to be run when an AJAX request starts.

Syntax:

$(document).ajaxStart(function())

Parameter Values

Parameter Description
function() It is a Required parameter and is used to specifies the function to run when the AJAX request starts

Here is an Example of jQuery ajaxStart() Method:


<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(){
$(this).html("<img src='demo_wait.gif'>");
});
$(".btn1").click(function(){
$(".div1").load("demo_ajax_load.asp");
});
});
</script>
</head>
<body>
<div class="div1"><h2>Change this text</h2></div>
<button class="btn1">Click me to Change Content</button>
</body>
</html>

Output:

Change this text


No Sidebar ads