var timeoutID;
var toDelay = 5000;
$("#loading")
.ajaxStart(function() {
// Delay the loading animation for "toDelay" milliseconds (5000 in this case, which is 5
// seconds)
timeoutID = setTimeout(function() {
$(this).show();
}, delay);
})
.ajaxStop(function() {
// Clear the timeout
clearTimeout(timeoutID);
// If the timeout gets cleared before 5 seconds have passed, then the loading
// animation is still hidden, so we don't need to hide it again
if(this.style.display != "none") {
$(this).hide();
}
});
On 11/8/06, Chris W. Parker <[EMAIL PROTECTED]> wrote:
Hello,
I've got a loading animation that appears each time a request is made
through AJAX but I'm thinking about getting rid of it altogether because
the loading happens so quickly. The animation is actually just kind of
annoying.
But I was thinking that instead of getting rid of it entirely I could
just make it appear if the loading takes longer than n-seconds. I'm
using ajaxStart() and ajaxStop() to show the animation.
Thanks,
Chris.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________ jQuery mailing list [email protected] http://jquery.com/discuss/
