jQuery ajaxSuccess Event

Beginner
8 min read
Updated: Oct 2026
5 examples
Live preview

What Is ajaxSuccess?

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.

Remember
$(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 });
NeedUse
Global “request succeeded”$(document).on("ajaxSuccess", fn)
Error onlyajaxError
Always finishedajaxComplete
One request only$.ajax(...).done(fn)
Hide loading when idleajaxStop

How to Use ajaxSuccess

Bind once on document, then any successful jQuery Ajax call can notify that handler.

  1. Attach the handler to document with .on("ajaxSuccess", handler).
  2. Make requests with $.ajax(), $.get(), $.post(), or .load().
  3. Optionally filter with ajaxOptions.url (or other settings).
  4. Read the body via jqXHR.responseText or the parsed data argument.
  5. Use global: false on requests that must stay silent.
PieceRequired?Role
documentYes (1.9+)Only valid bind target for global Ajax events
handlerYesfunction(event, jqXHR, ajaxOptions, data)
ajaxOptions.urlOptionalFilter which requests you react to
global: falseOptionalSkip all global Ajax events for that call

Pseudocode

Pseudocode
bind ajaxSuccess on document with handler(event, jqXHR, ajaxOptions, data)

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

    fire ajaxComplete
    if no other global Ajax requests are active:
        fire ajaxStop

Cheat Sheet

Keep these facts handy while wiring global success handlers.

TopicDetail
Bind$(document).on("ajaxSuccess", handler)
Unbind$(document).off("ajaxSuccess" [, handler])
Signaturefunction(event, jqXHR, ajaxOptions, data)
WhenSuccessful requests only (not errors)
SinceEvent 1.0 · .on() form 1.7 · document-only 1.9+
Response bodyjqXHR.responseText or parsed data
Filterif (ajaxOptions.url === "...")
Opt outglobal: false in $.ajax() / $.ajaxSetup()

Live Preview

Run a real $.get() and watch the global ajaxSuccess handler update the log.

Live demo uses a public JSON API. Needs network access.

Result
Ready — pick an action and click Run.

jQuery Examples

Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.

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");
});
Try It Yourself

How It Works

  1. Bind. .on("ajaxSuccess") on document listens globally.
  2. Click. .load() starts an Ajax request under the hood.
  3. Success. On a successful response, every ajaxSuccess handler runs.
  4. Update. The log text confirms the global event fired.

Example 2 — Filter by settings.url

Handlers run for every success — narrow them with the settings object.

jQuery
$(document).on("ajaxSuccess", function (event, xhr, settings) {
  if (settings.url === "ajax/test.html") {
    $(".log").text(
      "Triggered ajaxSuccess handler. The Ajax response was: " +
      xhr.responseText
    );
  }
});
Try It Yourself

How It Works

  1. Args. jQuery passes event, xhr, settings, and data.
  2. Compare. Check settings.url against the endpoint you care about.
  3. Read. Use xhr.responseText for the raw body (or data for parsed).
  4. Skip. Non-matching URLs leave your UI alone.

Example 3 — Append “Successful Request!”

Official demo: append a short status string for every successful request.

jQuery
$(document).on("ajaxSuccess", function (event, request, settings) {
  $("#msg").append(" Successful Request! ");
});
Try It Yourself

How It Works

  1. Global. One handler covers every qualifying successful Ajax call.
  2. Append. Each success adds another status fragment.
  3. Count. Parallel successes each fire their own ajaxSuccess.
  4. Use. Handy for a simple toast strip or debug log.

Example 4 — Opt Out with global: false

Private requests skip all global Ajax events, including ajaxSuccess.

jQuery
$(document).on("ajaxSuccess", function () {
  $("#log").append(" ajaxSuccess");
});

// Fires ajaxSuccess
$.get("/api/public");

// Does NOT fire ajaxSuccess
$.ajax({ url: "/api/silent", global: false });
Try It Yourself

How It Works

  1. Default. Ajax calls participate in global events.
  2. Opt out. global: false skips ajaxSuccess (and the other globals).
  3. Local still works. .done() / .fail() / .always() still run.
  4. When. Use for silent prefetch, polling, or third-party widgets.

Example 5 — ajaxSuccess vs .done()

Global event sees every success; .done() is tied to one call.

jQuery
var globalCount = 0;
var doneCount = 0;

$(document).on("ajaxSuccess", function () {
  globalCount++;
});

$.ajax("/a").done(function () { doneCount++; });
$.ajax("/b").done(function () { doneCount++; });

// After both succeed:
// globalCount === 2, doneCount === 2
// but each .done() only saw its own request
Try It Yourself

How It Works

  1. Global. One ajaxSuccess handler counts every successful request.
  2. Local. Each .done() only increments for its own jqXHR.
  3. Same totals. Counts can match, but the scope is different.
  4. Choose. Site-wide toast → global event; one call’s UI → .done().

Edge Cases & Pitfalls

Check these before relying on global success handlers in production.

target

Bind on document only (1.9+)

Handlers on window or other elements will not receive global Ajax events.

scope

Success only

ajaxSuccess skips failures. Use ajaxError or ajaxComplete when outcome is not guaranteed.

global

global: false stays silent

Those requests never trigger ajaxSuccess. Per-request .done() still works.

cost

Heavy work in every handler hurts

Parsing large responseText or updating lots of DOM on every success can slow busy pages — filter first.

Browser Support

ajaxSuccess has been part of jQuery since 1.0. Prefer $(document).on("ajaxSuccess", …) (1.7+). Since 1.9, handlers must attach to document.

✓ Stable · jQuery 1.0+

jQuery ajaxSuccess

Works in every browser that runs your loaded jQuery version. Prefer a current jQuery 3.x build for modern projects.

100% jQuery Ajax event
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
ajaxSuccess Universal

Bottom line: Safe for everyday apps. Bind on document, filter by URL when needed, and use global: false for silent background calls.

Performance Notes

ApproachCostBest for
One filtered ajaxSuccessCheapSite-wide success toasts / logging
Per-request .done()CheapUI update for a single call
Heavy DOM work every successExpensiveAvoid — filter or debounce

Global handlers are fine when they stay light. Filter by URL before touching the DOM, and prefer .done() for request-specific work.

Key Takeaways

  • Role: global “request succeeded” hook — not for errors.
  • Bind: $(document).on("ajaxSuccess", fn) — document only since 1.9.
  • Filter: inspect ajaxOptions.url; read body via jqXHR.responseText or data.
  • Local alternative: use .done() for one-request success UI.

One line: ajaxSuccess is jQuery’s global success-only Ajax event — bind it on document.

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.

Next: .ajaxSuccess() method

See the deprecated shorthand and how to migrate to .on("ajaxSuccess").

.ajaxSuccess() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful