.ajaxSuccess(handler) is jQuery’s legacy shorthand (since 1.0) for binding a global Ajax “request succeeded” handler on document. It runs only on success — not on error. Internally it is sugar for .on("ajaxSuccess", handler).
Remember
// Deprecated (since 3.5)
$(document).ajaxSuccess(function (event, jqXHR, ajaxOptions, data) {
// runs after every successful qualifying Ajax request
});
// Modern replacement
$(document).on("ajaxSuccess", handler);
// Bind only — no no-arg .ajaxSuccess() trigger form
// Opt out: $.ajax({ url: "/x", global: false })
Recognize the legacy call, know its four handler arguments, and migrate to .on() / .off().
Attach the handler to document with .ajaxSuccess(handler) (legacy) or .on("ajaxSuccess", handler) (preferred).
Make requests with $.ajax(), $.get(), $.post(), or .load().
Optionally filter with ajaxOptions.url; read jqXHR.responseText or parsed data.
Remove with .off("ajaxSuccess", 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(event, jqXHR, ajaxOptions, data)
ajaxOptions.url
Optional
Filter which requests you react to
global: false
Optional
Skip all global Ajax events for that call
Pseudocode
Pseudocode
call $(document).ajaxSuccess(handler)
→ internally: $(document).on("ajaxSuccess", handler)
when a jQuery Ajax request finishes:
if request.global === false:
do not fire ajaxSuccess
return
if request succeeded:
fire ajaxSuccess
for each registered handler:
call handler(event, jqXHR, ajaxOptions, data)
else:
fire ajaxError instead
to migrate:
replace .ajaxSuccess(fn) with .on("ajaxSuccess", fn)
remove with .off("ajaxSuccess", fn)
Reference
Cheat Sheet
Quick map from legacy shorthand to modern APIs.
Topic
Detail
Legacy bind
$(document).ajaxSuccess(handler) ⚠ deprecated 3.5
Modern bind
$(document).on("ajaxSuccess", handler)
Unbind
$(document).off("ajaxSuccess" [, handler])
Signature
function(event, jqXHR, ajaxOptions, data)
When
Successful requests only (not errors)
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 .ajaxSuccess() handler update the log.
Demo uses deprecated .ajaxSuccess() 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("ajaxSuccess") for new projects.
Example 1 — Basic $(document).ajaxSuccess(fn)
Canonical legacy pattern: log when any Ajax request succeeds after a click.
jQuery
$(document).ajaxSuccess(function () {
$(".log").text("Handler ran via .ajaxSuccess(function(){ ... }).");
});
$("#fetch").on("click", function () {
$.get("https://jsonplaceholder.typicode.com/posts/1");
});
Run $.get() → count increments
Click Remove → .off("ajaxSuccess", onSuccess)
Next $.get() → handler no longer runs
How It Works
Named fn. Anonymous handlers cannot be removed individually.
Bind..ajaxSuccess(onSuccess) stores that reference.
Remove..off("ajaxSuccess", onSuccess) detaches exactly that handler.
Avoid. Do not use deprecated .unbind("ajaxSuccess") in new code.
Edge Cases & Pitfalls
Watch for these when reading or migrating legacy Ajax code.
deprecated
Do not use in new code
.ajaxSuccess(handler) is deprecated since 3.5. Prefer .on("ajaxSuccess").
target
Bind on document only (1.9+)
Handlers on window or other elements will not receive global Ajax events.
scope
Success only
Failed requests skip .ajaxSuccess(). Use ajaxError or ajaxComplete when outcome is not guaranteed.
trigger
No no-arg trigger form
Unlike .click(), calling .ajaxSuccess() with no arguments does not fire the event.
Compatibility
Browser Support
The .ajaxSuccess() method has been part of jQuery since 1.0. Since 1.9, handlers must attach to document. Binding via .ajaxSuccess(handler) is deprecated since 3.5 but still functional in jQuery 3.x.
✓ Deprecated · jQuery 1.0+
jQuery .ajaxSuccess()
Works wherever your loaded jQuery version runs Ajax. Prefer .on('ajaxSuccess') 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
.ajaxSuccess()Legacy API
Bottom line: Safe in legacy jQuery projects. Migrate bindings to .on('ajaxSuccess') and cleanup to .off('ajaxSuccess') when updating code.
Analysis
Performance Notes
Approach
Cost
Best for
One filtered global handler
Cheap
Site-wide success toasts / logging
Per-request .done()
Cheap
UI update for a single call
Heavy DOM work every success
Expensive
Avoid — filter or debounce
Legacy and modern binds have the same cost. Keep handlers light, filter by URL before touching the DOM, and prefer .done() for request-specific work.
Remember
Key Takeaways
Role: legacy global “request succeeded” bind — not for errors.
Migrate:$(document).on("ajaxSuccess", fn) — preferred since 3.5.
Args:function(event, jqXHR, ajaxOptions, data) — filter with ajaxOptions.url.
Cleanup: use .off("ajaxSuccess", fn) — not .unbind().
One line:.ajaxSuccess() is deprecated sugar for .on("ajaxSuccess") on document.
Frequently Asked Questions
The .ajaxSuccess(handler) method binds a global function that runs whenever any qualifying jQuery Ajax request completes successfully. Attach it to document: $(document).ajaxSuccess(fn). It is bind-only (no trigger form). Deprecated since jQuery 3.5; use $(document).on("ajaxSuccess", handler) instead.
Yes. $(document).ajaxSuccess(handler) has been deprecated since jQuery 3.5 (available since 1.0). Prefer $(document).on("ajaxSuccess", handler) for new code. Legacy bindings still work in jQuery 3.x; migrate when you touch those files. Remove handlers with $(document).off("ajaxSuccess", handler).
ajaxSuccess is a global Ajax event, not a DOM event on a specific element. Since jQuery 1.9, all global Ajax handlers — including .ajaxSuccess(handler) — must bind to document. Correct legacy form: $(document).ajaxSuccess(fn). Modern form: $(document).on("ajaxSuccess", fn).
Four — the same as the ajaxSuccess event: function(event, jqXHR, ajaxOptions, data). Use jqXHR.responseText for the raw body, data for the processed response, and ajaxOptions.url to identify the request. Failed requests trigger ajaxError instead.
Replace $(document).ajaxSuccess(fn) with $(document).on("ajaxSuccess", fn). Use $(document).off("ajaxSuccess", fn) for cleanup instead of .unbind(). Under the hood, .ajaxSuccess(handler) already delegates to .on("ajaxSuccess") — migration is a straight rename for simple bindings.
Yes. jQuery 3.x keeps .ajaxSuccess(handler) for backward compatibility. It still binds correctly on document. Docs mark it deprecated since 3.5 to steer new projects toward .on(). Prefer the modern API covered in the jQuery ajaxSuccess event tutorial.