The .ajaxSuccess() method is jQuery’s legacy shorthand for binding global ajaxSuccess handlers on document. This tutorial covers $(document).ajaxSuccess(handler), the handler signature (event, jqXHR, ajaxOptions, data), why binding must target document since 1.9, migration to .on("ajaxSuccess") and cleanup with .off("ajaxSuccess"), and why the method is deprecated since jQuery 3.5. Unlike .click(), there is no trigger variant — only binding. The handler fires only on success — not on failure. For the modern ajaxSuccess event API, see the jQuery ajaxSuccess event tutorial.
01
.ajaxSuccess(fn)
Bind handler
02
document
Bind target
03
3 args
event, jqXHR, settings
04
.on()
Modern bind
05
.off()
Remove handler
06
Deprecated
Since 3.5
Fundamentals
Introduction
Before jQuery 1.7 unified events with .on() and .off(), global Ajax events had matching shorthand methods — .ajaxStart(), .ajaxSend(), .ajaxSuccess(), and others. The .ajaxSuccess(handler) method let you register a page-wide “request succeeded” callback in one short call: $(document).ajaxSuccess(function(){ ... }). It remains in jQuery 3.x for backward compatibility but is marked deprecated since 3.5.
Understanding .ajaxSuccess() matters when reading older admin panels, legacy jQuery plugins, and tutorials written before .on("ajaxSuccess") became standard. Unlike DOM event shorthands such as .click(), .ajaxSuccess() has only a binding form — there is no no-argument trigger variant. Modern jQuery binds the same global event explicitly: $(document).on("ajaxSuccess", handler). This page documents the shorthand API and shows how to migrate.
Concept
Understanding the .ajaxSuccess() Method
The official jQuery API describes .ajaxSuccess() as a way to register a handler to be called when Ajax requests complete. When you pass a function, jQuery registers it on document and calls it whenever a qualifying Ajax request completes successfully — failed requests trigger ajaxError instead. That is the same ajaxSuccess global event that .on("ajaxSuccess") handles today.
The handler receives four arguments even though the API signature lists only handler: event (the jQuery event object), jqXHR (the XMLHttpRequest wrapper — read jqXHR.responseText for the body), and ajaxOptions (the settings object passed to $.ajax()), plus data — the processed response. Requests with global: false still opt out — they do not trigger .ajaxSuccess() handlers.
⚠️
Deprecated since jQuery 3.5
Do not use $(document).ajaxSuccess(handler) in new code. Replace it with $(document).on("ajaxSuccess", handler). Remove handlers with $(document).off("ajaxSuccess", handler) — not .unbind("ajaxSuccess"). For event order, URL filtering, global: false, and comparison with .done(), read the jQuery ajaxComplete event tutorial.
Foundation
📝 Syntax
The .ajaxSuccess() method has one signature from the official jQuery API — binding only. There is no trigger form unlike .click():
1. Bind a handler — .ajaxSuccess( handler ) (deprecated since 3.5)
jQuery
$( document ).ajaxSuccess( handler )
handler — function invoked when any qualifying Ajax request succeeds. Official docs list Function(); the callback actually receives function( event, jqXHR, ajaxOptions, data ) { ... }.
Must attach to document since jQuery 1.9 — not window or other elements.
Returns the jQuery object (document wrapped) for chaining.
Modern replacement:$( document ).on( "ajaxSuccess", handler ).
$( document ).off( "ajaxSuccess" ); // remove all ajaxSuccess handlers
$( document ).off( "ajaxSuccess", myHandler ); // remove one handler
Do not use deprecated .unbind("ajaxSuccess") in new code. Store a named function reference when you need to remove a specific handler later.
Return value
.ajaxSuccess(handler) returns the original jQuery object for chaining.
Handler return values are ignored by jQuery’s global Ajax event system.
Cheat Sheet
⚡ Quick Reference
Goal
Legacy (.ajaxSuccess)
Modern replacement
Bind global complete handler
$(document).ajaxSuccess(fn) ⚠
$(document).on("ajaxSuccess", fn)
Handler signature
function(event, jqXHR, ajaxOptions, data)
Read parsed response
data (4th argument)
Read response text
jqXHR.responseText
Filter by URL
if (ajaxOptions.url === "/api/x")
Opt out of global events
$.ajax({ url: "/x", global: false })
Remove handlers
$(document).off("ajaxSuccess", fn)
Trigger ajaxSuccess programmatically
Not supported — no no-arg .ajaxSuccess() trigger form
Compare
📋 .ajaxSuccess() vs .on("ajaxSuccess") vs .off("ajaxSuccess")
Three related APIs — know which one binds and which one removes handlers. Unlike .click(), there is no trigger shorthand.
.ajaxSuccess()
deprecated
Legacy bind — $(document).ajaxSuccess(fn) — use modern API for new code
.on("ajaxSuccess")
bind
Modern binding since 1.7 — same behavior, clearer intent, reliable unbinding
.off("ajaxSuccess")
remove
Unbind handlers — pair with .on("ajaxSuccess") when cleaning up or in SPAs
ajaxComplete event
always
Global AjaxEvent — fires after success or error; pair with .ajaxSuccess() for outcome-specific hooks
Hands-On
Examples Gallery
Five examples cover basic binding, reading xhr.responseText, legacy logging, migration from .ajaxSuccess() to .on("ajaxSuccess"), and removing handlers with .off(). Use the Try-it links to run each snippet in the browser. Remember: binding with .ajaxSuccess(handler) is deprecated — these demos show legacy syntax you will encounter in older code.
📚 Binding & Inspecting
Legacy .ajaxSuccess() patterns for observing successful Ajax requests.
Example 1 — Basic $(document).ajaxSuccess(fn) + Button Triggers $.get()
The canonical legacy pattern — attach a function on document that runs when any qualifying Ajax request succeeds.
User clicks #fetch → $.get() runs Ajax request
When request succeeds → .log shows handler message
Works for $.ajax(), $.get(), $.post(), and .load()
Deprecated — prefer .on("ajaxSuccess", fn) for new code
How It Works
$(document).ajaxSuccess(fn) registers the function on document. jQuery internally routes this to .on("ajaxSuccess", fn). The handler runs when the request succeeds — not on failure.
Example 2 — Handler Reads xhr.responseText and settings.url
The official handler signature passes four arguments — filter by URL before reading the response body or parsed data.
Request to posts/1 completes → .log shows URL + responseText snippet
Request to other URLs → handler runs but if-block skipped
Official docs use parameter names xhr and settings
How It Works
Although the API lists handler as Function(), jQuery passes event, jqXHR, and ajaxOptions — same as the ajaxSuccess event. Compare settings.url before reading xhr.responseText.
Example 3 — Legacy Logging: Append “Successful Request!”
A common pattern in older codebases — append a status message whenever any Ajax request succeeds.
Each qualifying Ajax request → #msg gains " Successful Request! "
Three parallel requests → three appended messages
Ideal for a simple activity log or debug strip
How It Works
Because ajaxSuccess fires for every successful global request, appending to #msg builds a running log. Pair with URL filtering if you only want messages for specific endpoints. Migrate the binding to .on("ajaxSuccess") when refactoring.
📈 Migration & Cleanup
Compare legacy and modern APIs, and remove handlers with .off().
Example 4 — Migration: .ajaxSuccess(fn) vs .on("ajaxSuccess", fn)
Both bind the same global event — .on() is the recommended API for new code.
jQuery
// Legacy — deprecated since jQuery 3.5
$( document ).ajaxSuccess( function() {
$( "#out" ).text( "Legacy: .ajaxSuccess(function(){ ... })." );
} );
// Modern — use for new code
$( document ).on( "ajaxSuccess", function() {
$( "#out" ).text( "Modern: .on('ajaxSuccess', function(){ ... })." );
} );
Both handlers fire when $.get() completes
Legacy message from .ajaxSuccess(fn)
Modern message from .on("ajaxSuccess", fn)
Behavior is identical — only the API name differs
How It Works
Under the hood, .ajaxSuccess(fn) calls .on("ajaxSuccess", fn). Migration is a straight rename with no behavior change for simple bindings. The modern API also pairs cleanly with .off("ajaxSuccess", fn) for teardown.
Example 5 — Remove Handler with .off("ajaxSuccess")
Store a named function reference, then remove it with .off() — not deprecated .unbind().
Run $.get() → count increments
Click Remove → .off("ajaxSuccess", onSuccess)
Next $.get() completes but handler no longer runs — count unchanged
How It Works
Anonymous functions passed to .ajaxSuccess() cannot be removed individually — use a named function. .off("ajaxSuccess", onSuccess) removes exactly that handler. Do not call deprecated .unbind("ajaxSuccess") in new code.
Applications
🚀 Common Use Cases
Reading legacy code — recognize $(document).ajaxSuccess(fn) as equivalent to .on("ajaxSuccess", fn) in older admin panels.
Activity logging — legacy debug panels append “Request complete” via .ajaxSuccess() — migrate to .on() when refactoring.
Response inspection — read xhr.responseText in a global handler for development logging.
URL filtering — compare settings.url inside .ajaxSuccess(fn) before updating the DOM.
SPA teardown — remove global handlers with .off("ajaxSuccess", fn) when unmounting a view.
Third-party isolation — requests with global: false still opt out of .ajaxSuccess() handlers.
🧠 How .ajaxSuccess() Routes Through jQuery
1
You call .ajaxSuccess(handler)
jQuery treats the function argument as a bind request on document. There is no no-argument trigger form — unlike .click().
bind only
2
Internal delegation
.ajaxSuccess(handler) delegates internally to .on("ajaxSuccess", handler) — the handler is stored in jQuery’s event system on document.
.on("ajaxSuccess")
3
Ajax request succeeds
When a qualifying request completes successfully, jQuery triggers ajaxSuccess on document — unless the request used global: false.
global event
4
👉
Handler runs with four arguments
function(event, jqXHR, ajaxOptions, data) — use data for parsed JSON or jqXHR.responseText and filter by ajaxOptions.url. Returns the jQuery object for chaining.
Important
📝 Notes
Deprecated since jQuery 3.5 — do not use $(document).ajaxSuccess(handler) in new code. Use .on("ajaxSuccess") instead.
Attach to document since jQuery 1.9 — not window or other elements.
Binding only — no no-argument trigger form unlike .click() or .mousedown().
Handler receives (event, jqXHR, ajaxOptions, data) even though the API lists handler as Function().
Remove handlers with $(document).off("ajaxSuccess", handler) — not .unbind("ajaxSuccess").
Requests with global: false do not trigger .ajaxSuccess() handlers.
Legacy code using .ajaxSuccess() still runs in jQuery 3.x — migrate when you refactor those files.
The underlying ajaxSuccess global event works wherever jQuery’s Ajax transport runs. The .ajaxSuccess() method itself is a jQuery API — it works in jQuery 1.x, 2.x, and 3.x when bound to document since 1.9. Binding via .ajaxSuccess(handler) is deprecated since 3.5 but still functional.
✓ jQuery 1.0+
jQuery .ajaxSuccess() method
Supported across all jQuery versions you are likely to maintain. Deprecated binding since 3.5 — use .on('ajaxSuccess') for new projects. Requires jQuery Ajax — 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.
Wrap Up
Conclusion
The jQuery .ajaxSuccess() method is the legacy shorthand for binding global Ajax success handlers on document. Use $(document).ajaxSuccess(handler) to register a callback — deprecated since jQuery 3.5. The handler receives (event, jqXHR, ajaxOptions, data) and runs only when a qualifying request succeeds.
For new code, prefer $(document).on("ajaxSuccess", fn) for binding and $(document).off("ajaxSuccess", fn) for cleanup. When you encounter .ajaxSuccess() in older projects, recognize it, understand it, and migrate when practical. Continue with the jQuery ajaxComplete event tutorial for the global always-finish hook.
Write new code with deprecated $(document).ajaxSuccess(handler)
Attach global handlers to window — use document
Expect a no-arg .ajaxSuccess() trigger form — it does not exist
Use .unbind("ajaxSuccess") — it is also deprecated; use .off()
Expect .ajaxSuccess() on failed requests — use ajaxError or ajaxComplete instead
Summary
Key Takeaways
Knowledge Unlocked
Six things to remember about .ajaxSuccess()
Legacy bind, modern migrate.
6
Core concepts
.ac01
.ajaxSuccess(fn)
Bind
Deprecated
doc02
document
Bind here
Since 1.9
3×03
3 args
event, jqXHR, settings
Handler
.on04
.on("ajaxSuccess")
Modern
Replace
.off05
.off()
Remove
Cleanup
3.506
Deprecated
Since 3.5
Migrate
❓ Frequently Asked Questions
The .ajaxSuccess(handler) method binds a global function that runs whenever any qualifying jQuery Ajax request completes successfully. You must attach it to document: $(document).ajaxSuccess(fn). Unlike .click(), there is no no-argument trigger form — only binding. The method has been deprecated since jQuery 3.5; use $(document).on('ajaxSuccess', handler) instead.
Yes — $(document).ajaxSuccess(handler) is deprecated since jQuery 3.5 (available since jQuery 1.0). Use $(document).on('ajaxSuccess', handler) for new code. Existing legacy code continues to run in jQuery 3.x; migrate when you touch those files. Remove handlers with $(document).off('ajaxSuccess', handler), not the deprecated .unbind() API.
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 be bound to document, not window or other elements. The correct legacy pattern is $(document).ajaxSuccess(fn); the modern equivalent is $(document).on('ajaxSuccess', fn).
Four arguments: function(event, jqXHR, ajaxOptions, data). The official API lists handler as Function() but jQuery passes the jQuery event, the jqXHR object, the settings used to create the request, and data — the processed response (parsed JSON, HTML, etc.). Failed requests trigger ajaxError instead — not .ajaxSuccess().
Replace $(document).ajaxSuccess(fn) with $(document).on('ajaxSuccess', fn). Replace cleanup via .unbind('ajaxSuccess') with $(document).off('ajaxSuccess', fn). Under the hood, .ajaxSuccess(handler) already delegates to .on('ajaxSuccess') — migration is a straight rename with no behavior change for simple bindings.
.ajaxSuccess() fires only when a global request succeeds — ideal for success toasts and analytics. .ajaxComplete() fires after every individual request finishes, success or error, with the same three core arguments (no data). Use ajaxComplete when you need both outcomes.
Did you know?
Unlike DOM event shorthands such as .click(), which support both binding (.click(fn)) and triggering (no-arg .click()), .ajaxSuccess() is bind-only. You cannot programmatically fire global Ajax events through a no-argument .ajaxSuccess() call — they fire automatically when jQuery’s Ajax transport completes a request successfully. The deprecated method is simply sugar for .on("ajaxSuccess", fn) on document. jQuery also passes a fourth data argument with the parsed response.