jQuery ajaxSuccess Event

Beginner
5 min read
Updated: Nov 2026
3 examples
Ajax

Definition

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 });
CallWhat it does
documentOnly valid bind target for global Ajax events
handlerfunction(event, jqXHR, ajaxOptions, data)
ajaxOptions.urlFilter which requests you react to
global: falseSkip 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

ParameterDescription
Step 1Attach the handler to document with .on("ajaxSuccess", handler).
Step 2Make requests with $.ajax(), $.get(), $.post(), or .load().
Step 3Optionally filter with ajaxOptions.url (or other settings).

Return Value

Return ValueDescription
jQuery objectMost 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");
});
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.

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).

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.

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() Method tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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