ajaxSuccess is a global AjaxEvent (since jQuery 1.0; .on() binding since 1.7). jQuery triggers it on document whenever any qualifying Ajax request completes successfully. All registered handlers run.
Syntax
Start with these common calls. Keep them short and readable.
jQuery
$(document).on("ajaxSuccess", function (event, jqXHR, ajaxOptions, data) {
// runs after every successful qualifying Ajax request
});
// Order (on success):
// ajaxSuccess → ajaxComplete → (ajaxStop when idle)
// Opt out for one call:
$.ajax({ url: "/x", global: false });
Call
What it does
document
Only valid bind target for global Ajax events
handler
function(event, jqXHR, ajaxOptions, data)
ajaxOptions.url
Filter which requests you react to
global: false
Skip all global Ajax events for that call
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Attach the handler to document with .on("ajaxSuccess", handler).
Step 2
Make requests with $.ajax(), $.get(), $.post(), or .load().
Step 3
Optionally filter with ajaxOptions.url (or other settings).
Return Value
Return Value
Description
jQuery object
Most setters and traversing helpers return the jQuery collection so you can chain more methods.
jQuery Examples
Example 1 — Document Handler + .load()
Official pattern: log a message when any Ajax request succeeds after a click.
jQuery
$(document).on("ajaxSuccess", function () {
$(".log").text("Triggered ajaxSuccess handler.");
});
$(".trigger").on("click", function () {
$(".result").load("ajax/test.html");
});
Each successful request →
#msg gains " Successful Request! "
Three parallel successes → three appends
How It Works
Global. One handler covers every qualifying successful Ajax call.
Append. Each success adds another status fragment.
Count. Parallel successes each fire their own ajaxSuccess.
Frequently Asked Questions
ajaxSuccess is a global AjaxEvent that fires whenever any qualifying jQuery Ajax request completes successfully. Bind it with $(document).on("ajaxSuccess", handler) (since 1.7). Every registered handler runs for every successful request. Failed requests trigger ajaxError instead.
Since jQuery 1.9, all global Ajax event handlers must be bound to document — not window or other elements. Use $(document).on("ajaxSuccess", fn) and remove with $(document).off("ajaxSuccess", fn).
No. It runs only on success. Use ajaxError for failures, or ajaxComplete when you need a hook after every finished request.
ajaxSuccess is a global document event — one handler observes every qualifying successful request on the page. done() is per-request on the jqXHR from $.ajax() — it runs only for that call. Use global events for site-wide success UI; use done() for request-specific updates.
When $.ajax() or $.ajaxSetup() sets global: false, that request opts out of all global Ajax events. ajaxSuccess will not fire for it. Per-request done(), fail(), and always() still run.
Four: function(event, jqXHR, ajaxOptions, data). event is the jQuery event; jqXHR is the request object (read responseText); ajaxOptions is the settings used to create the request (filter with ajaxOptions.url); data is the processed response body.
The shorthand method .ajaxSuccess(handler) is deprecated as of jQuery 3.5. Prefer $(document).on("ajaxSuccess", handler) — the event API this page teaches.