.ajaxStop(handler) is jQuery’s legacy shorthand (since 1.0) for binding a global Ajax “batch idle” handler on document. It runs when the last qualifying request finishes and none remain active. Internally it is sugar for .on("ajaxStop", handler).
Remember
// Deprecated (since 3.5)
$(document).ajaxStop(function () {
// runs when no global Ajax requests remain active
});
// Modern replacement
$(document).on("ajaxStop", handler);
// Bind only — no no-arg .ajaxStop() trigger form
// Opt out: $.ajax({ url: "/x", global: false })
Recognize the legacy call, know it has no handler args, and migrate to .on() / .off().
Attach the handler to document with .ajaxStop(handler) (legacy) or .on("ajaxStop", handler) (preferred).
Pair with ajaxStart if you show a spinner when activity begins.
Remember: the handler is function() — no jqXHR / settings.
Remove with .off("ajaxStop", handler) — not .unbind().
Use global: false on requests that must stay silent.
Piece
Required?
Role
document
Yes (1.9+)
Only valid bind target for global Ajax events
handler
Yes
function() — no extra arguments
ajaxStart
Recommended
Show loading UI when the first request begins
global: false
Optional
Skip all global Ajax events for that call
Pseudocode
Pseudocode
call $(document).ajaxStop(handler)
→ internally: $(document).on("ajaxStop", handler)
when a jQuery Ajax request finishes:
if request.global === false:
do not count it / do not fire ajaxStop for it
return
decrement active global request count
fire ajaxComplete for this request
if active global request count === 0:
fire ajaxStop
for each registered handler:
call handler()
to migrate:
replace .ajaxStop(fn) with .on("ajaxStop", fn)
remove with .off("ajaxStop", fn)
Reference
Cheat Sheet
Quick map from legacy shorthand to modern APIs.
Topic
Detail
Legacy bind
$(document).ajaxStop(handler) ⚠ deprecated 3.5
Modern bind
$(document).on("ajaxStop", handler)
Unbind
$(document).off("ajaxStop" [, handler])
Signature
function() — no jqXHR / settings
When
Last global request ends (active count → 0)
Since
Method 1.0 · document-only 1.9+ · deprecated 3.5
Trigger form
None — bind only (unlike .click())
Opt out
global: false in $.ajax() / $.ajaxSetup()
Try it
Live Preview
Run a real $.get() and watch the legacy .ajaxStop() handler update the log.
Demo uses deprecated .ajaxStop() plus a public JSON API. Needs network access.
Result
Ready — pick an action and click Run.
Code
jQuery Examples
Short, copy-ready snippets using the legacy shorthand. Prefer .on("ajaxStop") for new projects.
Example 1 — Basic $(document).ajaxStop(fn)
Canonical legacy pattern: log when global Ajax activity ends after a click.
jQuery
$(document).ajaxStop(function () {
$(".log").text("Handler ran via .ajaxStop(function(){ ... }).");
});
$("#fetch").on("click", function () {
$.get("https://jsonplaceholder.typicode.com/posts/1");
});
Run $.get() → count increments when idle
Click Remove → .off("ajaxStop", onStop)
Next $.get() → handler no longer runs
How It Works
Named fn. Anonymous handlers cannot be removed individually.
Bind..ajaxStop(onStop) stores that reference.
Remove..off("ajaxStop", onStop) detaches exactly that handler.
Avoid. Do not use deprecated .unbind("ajaxStop") in new code.
Edge Cases & Pitfalls
Watch for these when reading or migrating legacy Ajax code.
deprecated
Do not use in new code
.ajaxStop(handler) is deprecated since 3.5. Prefer .on("ajaxStop").
target
Bind on document only (1.9+)
Handlers on window or other elements will not receive global Ajax events.
args
No jqXHR / settings
The handler is function(). Read response details from ajaxComplete instead.
trigger
No no-arg trigger form
Unlike .click(), calling .ajaxStop() with no arguments does not fire the event.
Compatibility
Browser Support
The .ajaxStop() method has been part of jQuery since 1.0. Since 1.9, handlers must attach to document. Binding via .ajaxStop(handler) is deprecated since 3.5 but still functional in jQuery 3.x.
✓ Deprecated · jQuery 1.0+
jQuery .ajaxStop()
Works wherever your loaded jQuery version runs Ajax. Prefer .on('ajaxStop') for new projects. fetch() and axios do not trigger jQuery global events.
100%With jQuery Ajax
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
.ajaxStop()Legacy API
Bottom line: Safe in legacy jQuery projects. Migrate bindings to .on('ajaxStop') and cleanup to .off('ajaxStop') when updating code.
Analysis
Performance Notes
Approach
Cost
Best for
One light .ajaxStop() (toggle UI)
Cheap
Page-wide loading spinner
ajaxStart + ajaxStop pair
Cheap
Show / hide loading for a batch
Heavy DOM work on every stop
Expensive
Avoid — keep the handler tiny
Legacy and modern binds have the same cost. Keep handlers light — toggle visibility only — and prefer ajaxComplete for per-request work.
Remember
Key Takeaways
Role: legacy global “batch idle” bind — hide loading UI.
Migrate:$(document).on("ajaxStop", fn) — preferred since 3.5.
Args:function() — no jqXHR; use ajaxComplete for details.
Cleanup: use .off("ajaxStop", fn) — not .unbind().
One line:.ajaxStop() is deprecated sugar for .on("ajaxStop") on document.
Frequently Asked Questions
The .ajaxStop(handler) method binds a global function that runs when all qualifying jQuery Ajax requests have completed — when no global requests remain active. Attach it to document: $(document).ajaxStop(fn). It is bind-only (no trigger form). Deprecated since jQuery 3.5; use $(document).on("ajaxStop", handler) instead.
Yes. $(document).ajaxStop(handler) has been deprecated since jQuery 3.5 (available since 1.0). Prefer $(document).on("ajaxStop", handler) for new code. Legacy bindings still work in jQuery 3.x; migrate when you touch those files. Remove handlers with $(document).off("ajaxStop", handler).
ajaxStop is a global Ajax event, not a DOM event on a specific element. Since jQuery 1.9, all global Ajax handlers — including .ajaxStop(handler) — must bind to document. Correct legacy form: $(document).ajaxStop(fn). Modern form: $(document).on("ajaxStop", fn).
None. The official API lists handler as Function() with no parameters — function() { ... }. Unlike ajaxComplete, you do not receive event, jqXHR, or ajaxOptions. Use ajaxComplete for per-request details.
Replace $(document).ajaxStop(fn) with $(document).on("ajaxStop", fn). Use $(document).off("ajaxStop", fn) for cleanup instead of .unbind(). Under the hood, .ajaxStop(handler) already delegates to .on("ajaxStop") — migration is a straight rename for simple bindings.
.ajaxStop() fires once when the last global request finishes — ideal for hiding page-wide loading UI. ajaxComplete fires after every individual request and receives (event, jqXHR, ajaxOptions). Pair .ajaxStop() with .ajaxStart() (or their .on() equivalents) to show and hide loading UI for a batch.