> > On 9/2/07, Erik Beeson <[EMAIL PROTECTED]> wrote: > > If ajaxStop is called before the setTimeout callback in > > ajaxStart is run, active will be false, so the addClass() on line 9 > > won't get executed. > > Without this, if ajaxStop ran before the setTimeout callback, the > > removeClass() would happen before the addClass(), so the > > class would never get removed.
> From: barophobia > > Why would ajaxStop ever be called before ajaxStart? > > 1. ajax request begins > 2. ajaxStart() begins counting > 3. ajax request ends before timeout period > 4. ajaxStart() is canceled (addClass() never gets executed) > 5. ajaxStop() starts and calls removeClass() > 6. nothing is displayed > > Is that the wrong progression? Yes. You left out the setTimeout, which is never canceled. (And step 4 doesn't happen either - nobody "cancels" the ajaxStart - that function has already been called.) Assume the AJAX request takes 75 milliseconds. Then, the code in http://www.pastebin.ca/678318 goes like this: 0ms: ajax request begins 0-1ms: ajaxStart() runs and calls setTimeout() 75ms: ajaxStop() runs and calls removeClass() 100ms: setTimeout callback runs and calls addClass() See http://www.pastebin.ca/679254 for the latest and greatest version... :-) -Mike