#13680 closed bug (notabug)
ajaxStart and ajaxStop no longer gets fired if error in ajax success/error callbacks
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.9.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
In our application, we have a global loading animation which blocks during ajax requests. However, if there is a javascript exception in the ajax success/error callbacks, the animation no longer gets triggered.
I wrote a test case to illustrate the problem. http://jsfiddle.net/QwYpD/4/
Thanks, Miguel
Change History (3)
comment:1 Changed 10 years ago by
Resolution: | → notabug |
---|---|
Status: | new → closed |
comment:2 Changed 10 years ago by
We always stop animation, but why is it that the global ajax start/stop no longer get fired after an exception? Shouldn't they continue to work afterwards on subsequent calls?
comment:3 Changed 10 years ago by
It's because we have a global counter that is not properly reset to 0 because the exception bubbled. One of the reasons why I always tell people to prefer prefilters whenever applicable. ajaxStart
and ajaxStop
take concurrent requests into account, a feature that is actually rarely useful and can easily be handled by a prefilter using a simple counter.
You could try and reset jQuery.active
to 0 but I'm not sure that's a road you want to get down to.
You should handle exceptions in your callbacks. jQuery will halt whenever an unhandled exception bubbles up which makes it much easier to spot bugs in applications.
You could also use a prefilter rather than ajaxStart and ajaxStop: