My current web app project makes heavy use of ajax calls. Most of them are fast and respond almost immediately. So, showing ajax loader all the time is not necessary. But I want to show an ajax loader when ajax calls take longer then 250ms (or so). Otherwise the users might be confused and keep clicking on links over and over again. :)
Any ideas how to accomplish that using jQuery?
I have no previous experience with jQuery but to achieve a simple delay to execution of some code, just use this:
setTimeout ("foo()", 250);
where foo() is the function responsible for loading... indication.
Can you use a Javascript timer to trigger after 250ms to display your 'loading...' message ?
Activate this on ajaxSend(), and disable it on ajaxComplete() (and clear the 'loading...' message if reqd), and so the implementation should be transparent to whatever Ajax calls you make.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With