[jQuery] How to show loading div only when loading takes longer than a certain amount of time

2006-11-08 Thread Chris W. Parker
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

Re: [jQuery] How to show loading div only when loading takes longer than a certain amount of time

2006-11-08 Thread Chris W. Parker
On Wednesday, November 08, 2006 10:44 AM Mark Gibson said: This may work (untested): [snip] ajaxStart delays the animation by 2 seconds using setTimeout, and ajaxStop cancels the timeout function (if it hasn't already been trigger) and stops the anim. It sort of works! Now it won't show

Re: [jQuery] How to show loading div only when loading takes longer than a certain amount of time

2006-11-08 Thread Aaron Heimlich
Off the top of my head (read: completely untested), you could do something like: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() {