jQuery .ajaxSuccess() Method

Beginner
⚠️ Deprecated since 3.5
⏱️ 11 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Ajax events

What You’ll Learn

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

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.

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.

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

2. Official jQuery API migration note

jQuery
// Deprecated binding
$( document ).ajaxSuccess( function( event, xhr, settings ) {
  console.log( "Request succeeded:", settings.url );
} );

// Modern binding
$( document ).on( "ajaxSuccess", function( event, xhr, settings ) {
  console.log( "Request succeeded:", settings.url );
} );

// Remove handler — use .off(), not .unbind()
$( document ).off( "ajaxSuccess", myHandler );

3. Unbind — $(document).off("ajaxSuccess" [, handler])

jQuery
$( 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.

⚡ Quick Reference

GoalLegacy (.ajaxSuccess)Modern replacement
Bind global complete handler$(document).ajaxSuccess(fn)$(document).on("ajaxSuccess", fn)
Handler signaturefunction(event, jqXHR, ajaxOptions, data)
Read parsed responsedata (4th argument)
Read response textjqXHR.responseText
Filter by URLif (ajaxOptions.url === "/api/x")
Opt out of global events$.ajax({ url: "/x", global: false })
Remove handlers$(document).off("ajaxSuccess", fn)
Trigger ajaxSuccess programmaticallyNot supported — no no-arg .ajaxSuccess() trigger form

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

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.

jQuery
$( document ).ajaxSuccess( function() {
  $( ".log" ).text( "Handler ran via .ajaxSuccess(function(){ ... })." );
} );

$( "#fetch" ).on( "click", function() {
  $.get( "https://jsonplaceholder.typicode.com/posts/1" );
} );
Try It Yourself

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.

jQuery
var targetUrl = "https://jsonplaceholder.typicode.com/posts/1";

$( document ).ajaxSuccess( function( event, xhr, settings ) {
  if ( settings.url === targetUrl ) {
    $( ".log" ).text(
      "URL: " + settings.url + " | responseText: " +
      xhr.responseText.substring( 0, 100 ) + "..."
    );
  }
} );
Try It Yourself

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.

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

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

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

jQuery
var count = 0;

function onSuccess() {
  count++;
  $( ".log" ).text( "Handler active — ajaxSuccess count: " + count );
}

$( document ).ajaxSuccess( onSuccess );

$( "#remove" ).on( "click", function() {
  $( document ).off( "ajaxSuccess", onSuccess );
  $( ".log" ).text( "Handler removed — count stays " + count + "." );
} );
Try It Yourself

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.

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

📝 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.
  • For event order, comparison with .done(), and the complete modern workflow, see the jQuery ajaxComplete event tutorial.

Browser Support

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 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() Legacy API

Bottom line: Safe in legacy jQuery projects. Migrate bindings to .on('ajaxSuccess') and cleanup to .off('ajaxSuccess') when updating code.

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.

💡 Best Practices

✅ Do

  • Use $(document).on("ajaxSuccess", handler) for all new global bindings
  • Bind on document — required since jQuery 1.9
  • Store named function references when you need to remove handlers later
  • Remove handlers with $(document).off("ajaxSuccess", fn) on SPA teardown
  • Read the modern ajaxSuccess event tutorial for full API coverage

❌ Don’t

  • 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

Key Takeaways

Knowledge Unlocked

Six things to remember about .ajaxSuccess()

Legacy bind, modern migrate.

6
Core concepts
doc 02

document

Bind here

Since 1.9
03

3 args

event, jqXHR, settings

Handler
.on 04

.on("ajaxSuccess")

Modern

Replace
.off 05

.off()

Remove

Cleanup
3.5 06

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.

Next: ajaxComplete Event

Learn the global handler that runs after every Ajax request finishes — success or error.

ajaxComplete event 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.

6 people found this page helpful