Basically that's the question (parentheses are important)
Asked
Active
Viewed 8,127 times
31
-
I was wondering the same based on the two different answers here: https://stackoverflow.com/questions/11961438/implement-a-loading-indicator-for-a-jquery-ajax-call – SharpC May 11 '19 at 11:01
1 Answers
80
.ajaxStart()
and .ajaxStop()
are for all requests together, ajaxStart
fires when the first simultaneous request starts, ajaxStop
fires then the last of that simultaneous batch finishes.
So say you're making 3 requests all at once, ajaxStart()
fires when the first starts, ajaxStop()
fires when the last one (they don't necessarily finish in order) comes back.
These events don't get any arguments because they're for a batch of requests:
.ajaxStart( handler() )
.ajaxStop( handler() )
.ajaxSend()
and .ajaxComplete()
fire once per request as they send/complete. This is why these handlers are passed arguments and the global/batch ones are not:
.ajaxSend( handler(event, XMLHttpRequest, ajaxOptions) )
.ajaxComplete( handler(event, XMLHttpRequest, ajaxOptions) )
For a single documentation source, the Global Ajax Events section of the API is what you're after.

OMi Shah
- 5,768
- 3
- 25
- 34

Nick Craver
- 623,446
- 136
- 1,297
- 1,155
-
5this answer is very clear, worthy of being jQuery documentation in my opinion. – rocketsarefast Mar 31 '12 at 01:30
-
1So basically, `ajaxStart` and `ajaxStop` are good for easy ways to, say, toggle a `loading` class on your document. – M Miller Aug 07 '14 at 04:09
-
Feel free to extend this live exampe I started playing with http://jsfiddle.net/e4z9bv6k/ – Adriano Sep 15 '14 at 08:44
-
please someone correct the 2nd link in this answer as it takes me to a 404 page. – manian Mar 27 '20 at 23:52