Jquery and multiple Ajax
I have had 2 occasions where I need to know when the ajax call have been finished:
- When in the beginning of page I have to load specific items that the user have been seen last time
- When the page was full with ajax call – and there was also a “submit” button that should send the information (saved already ) that the user have finished entering the fields .
So – jquery have 2 methods: ajaxStart and ajaxStop.
Code:
Put 2 divs on the page :
<div id=”divWait” style=”display:none”> Please wait…</div>
<div id=”divOK” style=”display:none”> All data submitted</div>
And put this on javascript:
$(“#divWait”).ajaxStart(function() { $(“#divWait”).show(); $(“#divOK”).hide(); }); $(“#divWait”).ajaxStop(function() { $(“#divWait”).hide(); $(“#divOK”).show(); });
Leave a Reply