Display Loading Image when AJAX Call is in Progress Example

By Hardik Savani April 3, 2023 Category : Javascript jQuery Ajax

Hi,

Are you looking for an example of display loading image on ajax call. In this article, we will implement a jquery show loading image on ajax call. step by step explain load image ajax javascript. I would like to share with you ajax while processing. follow the below example for show image while ajax loading.

Sometimes, we want to display a loading image, animation, or text when firing every Ajax request, not just for one Ajax request. If you want to display an image for every Ajax request, you can use the example below. I use the ajaxStart() and ajaxComplete() functions to show an image until all POST or GET Ajax requests are completed. These functions will execute once for each $.ajax request.

Example:

<script type="text/javascript">

$(document).ready(function()

{

$(document).ajaxStart(function(){

$('#process_img').css("display", "block");

});

$(document).ajaxComplete(function(){

$('#process_img').css("display", "none");

});

});

</script>

I hope it can help you...

Tags :
Shares