JQuery - Display loading image on ajax call example

By Hardik Savani | April 12, 2016 | | 50195 Viewer | Category : Javascript jQuery Ajax


Sometimes, we want to display loading image or animation or text when fire every ajax request. In not for only one ajax request, but if you want to load image on every ajax request then you can do that using bellow example.

I use ajaxStart() and ajaxComplete() function for show image until All POST or GET Ajax request. this both function will execute one 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>



Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.