The .ajaxComplete() method is jQuery’s legacy shorthand for binding global ajaxComplete handlers on document. This tutorial covers $(document).ajaxComplete(handler), the handler signature (event, jqXHR, ajaxOptions), why binding must target document since 1.9, migration to .on("ajaxComplete") and cleanup with .off("ajaxComplete"), and why the method is deprecated since jQuery 3.5. Unlike .click(), there is no trigger variant — only binding. For the modern ajaxComplete event API, see the jQuery ajaxComplete event tutorial.
01
.ajaxComplete(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(), .ajaxComplete(), and others. The .ajaxComplete(handler) method let you register a page-wide “request finished” callback in one short call: $(document).ajaxComplete(function(){ ... }). It remains in jQuery 3.x for backward compatibility but is marked deprecated since 3.5.
Understanding .ajaxComplete() matters when reading older admin panels, legacy jQuery plugins, and tutorials written before .on("ajaxComplete") became standard. Unlike DOM event shorthands such as .click(), .ajaxComplete() has only a binding form — there is no no-argument trigger variant. Modern jQuery binds the same global event explicitly: $(document).on("ajaxComplete", handler). This page documents the shorthand API and shows how to migrate.
Concept
Understanding the .ajaxComplete() Method
The official jQuery API describes .ajaxComplete() 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 after every qualifying Ajax request finishes — whether the server returned 200 or the call failed. That is the same ajaxComplete global event that .on("ajaxComplete") handles today.
The handler receives three 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()). Requests with global: false still opt out — they do not trigger .ajaxComplete() handlers.
⚠️
Deprecated since jQuery 3.5
Do not use $(document).ajaxComplete(handler) in new code. Replace it with $(document).on("ajaxComplete", handler). Remove handlers with $(document).off("ajaxComplete", handler) — not .unbind("ajaxComplete"). For event order, URL filtering, global: false, and comparison with .always(), read the jQuery ajaxComplete event tutorial.
Foundation
📝 Syntax
The .ajaxComplete() method has one signature from the official jQuery API — binding only. There is no trigger form unlike .click():
1. Bind a handler — .ajaxComplete( handler ) (deprecated since 3.5)
jQuery
$( document ).ajaxComplete( handler )
handler — function invoked when any qualifying Ajax request completes. Official docs list Function(); the callback actually receives function( event, jqXHR, ajaxOptions ) { ... }.
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( "ajaxComplete", handler ).
$( document ).off( "ajaxComplete" ); // remove all ajaxComplete handlers
$( document ).off( "ajaxComplete", myHandler ); // remove one handler
Do not use deprecated .unbind("ajaxComplete") in new code. Store a named function reference when you need to remove a specific handler later.
Return value
.ajaxComplete(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 (.ajaxComplete)
Modern replacement
Bind global complete handler
$(document).ajaxComplete(fn) ⚠
$(document).on("ajaxComplete", fn)
Handler signature
function(event, jqXHR, ajaxOptions)
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("ajaxComplete", fn)
Trigger ajaxComplete programmatically
Not supported — no no-arg .ajaxComplete() trigger form
Compare
📋 .ajaxComplete() vs .on("ajaxComplete") vs .off("ajaxComplete")
Three related APIs — know which one binds and which one removes handlers. Unlike .click(), there is no trigger shorthand.
.ajaxComplete()
deprecated
Legacy bind — $(document).ajaxComplete(fn) — use modern API for new code
.on("ajaxComplete")
bind
Modern binding since 1.7 — same behavior, clearer intent, reliable unbinding
.off("ajaxComplete")
remove
Unbind handlers — pair with .on("ajaxComplete") when cleaning up or in SPAs
ajaxComplete event
concept
Global AjaxEvent — fires after success or error; full guide on the event tutorial page
Hands-On
Examples Gallery
Five examples cover basic binding, reading xhr.responseText, legacy logging, migration from .ajaxComplete() to .on("ajaxComplete"), and removing handlers with .off(). Use the Try-it links to run each snippet in the browser. Remember: binding with .ajaxComplete(handler) is deprecated — these demos show legacy syntax you will encounter in older code.
📚 Binding & Inspecting
Legacy .ajaxComplete() patterns for observing completed Ajax requests.
Example 1 — Basic $(document).ajaxComplete(fn) + Button Triggers $.get()
The canonical legacy pattern — attach a function on document that runs when any qualifying Ajax request completes.
User clicks #fetch → $.get() runs Ajax request
When request completes → .log shows handler message
Works for $.ajax(), $.get(), $.post(), and .load()
Deprecated — prefer .on("ajaxComplete", fn) for new code
How It Works
$(document).ajaxComplete(fn) registers the function on document. jQuery internally routes this to .on("ajaxComplete", fn). The handler runs after the request completes — success or error.
Example 2 — Handler Reads xhr.responseText and settings.url
The official handler signature passes three arguments — filter by URL before reading the response body.
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 ajaxComplete event. Compare settings.url before reading xhr.responseText.
Example 3 — Legacy Logging: Append “Request Complete.”
A common pattern in older codebases — append a status message whenever any Ajax request finishes.
Each qualifying Ajax request → #msg gains " Request Complete. "
Three parallel requests → three appended messages
Ideal for a simple activity log or debug strip
How It Works
Because ajaxComplete fires for every 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("ajaxComplete") when refactoring.
📈 Migration & Cleanup
Compare legacy and modern APIs, and remove handlers with .off().
Example 4 — Migration: .ajaxComplete(fn) vs .on("ajaxComplete", fn)
Both bind the same global event — .on() is the recommended API for new code.
jQuery
// Legacy — deprecated since jQuery 3.5
$( document ).ajaxComplete( function() {
$( "#out" ).text( "Legacy: .ajaxComplete(function(){ ... })." );
} );
// Modern — use for new code
$( document ).on( "ajaxComplete", function() {
$( "#out" ).text( "Modern: .on('ajaxComplete', function(){ ... })." );
} );
Both handlers fire when $.get() completes
Legacy message from .ajaxComplete(fn)
Modern message from .on("ajaxComplete", fn)
Behavior is identical — only the API name differs
How It Works
Under the hood, .ajaxComplete(fn) calls .on("ajaxComplete", fn). Migration is a straight rename with no behavior change for simple bindings. The modern API also pairs cleanly with .off("ajaxComplete", fn) for teardown.
Example 5 — Remove Handler with .off("ajaxComplete")
Store a named function reference, then remove it with .off() — not deprecated .unbind().
Run $.get() → count increments
Click Remove → .off("ajaxComplete", onComplete)
Next $.get() completes but handler no longer runs — count unchanged
How It Works
Anonymous functions passed to .ajaxComplete() cannot be removed individually — use a named function. .off("ajaxComplete", onComplete) removes exactly that handler. Do not call deprecated .unbind("ajaxComplete") in new code.
Applications
🚀 Common Use Cases
Reading legacy code — recognize $(document).ajaxComplete(fn) as equivalent to .on("ajaxComplete", fn) in older admin panels.
Activity logging — legacy debug panels append “Request complete” via .ajaxComplete() — migrate to .on() when refactoring.
Response inspection — read xhr.responseText in a global handler for development logging.
URL filtering — compare settings.url inside .ajaxComplete(fn) before updating the DOM.
SPA teardown — remove global handlers with .off("ajaxComplete", fn) when unmounting a view.
Third-party isolation — requests with global: false still opt out of .ajaxComplete() handlers.
🧠 How .ajaxComplete() Routes Through jQuery
1
You call .ajaxComplete(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
.ajaxComplete(handler) delegates internally to .on("ajaxComplete", handler) — the handler is stored in jQuery’s event system on document.
.on("ajaxComplete")
3
Ajax request completes
After ajaxSuccess or ajaxError, jQuery triggers ajaxComplete on document — unless the request used global: false.
global event
4
👉
Handler runs with three arguments
function(event, jqXHR, ajaxOptions) — read jqXHR.responseText and filter by ajaxOptions.url. Returns the jQuery object for chaining.
Important
📝 Notes
Deprecated since jQuery 3.5 — do not use $(document).ajaxComplete(handler) in new code. Use .on("ajaxComplete") 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) even though the API lists handler as Function().
Remove handlers with $(document).off("ajaxComplete", handler) — not .unbind("ajaxComplete").
Requests with global: false do not trigger .ajaxComplete() handlers.
Legacy code using .ajaxComplete() still runs in jQuery 3.x — migrate when you refactor those files.
The underlying ajaxComplete global event works wherever jQuery’s Ajax transport runs. The .ajaxComplete() 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 .ajaxComplete(handler) is deprecated since 3.5 but still functional.
✓ jQuery 1.0+
jQuery .ajaxComplete() method
Supported across all jQuery versions you are likely to maintain. Deprecated binding since 3.5 — use .on('ajaxComplete') 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
.ajaxComplete()Legacy API
Bottom line: Safe in legacy jQuery projects. Migrate bindings to .on('ajaxComplete') and cleanup to .off('ajaxComplete') when updating code.
Wrap Up
Conclusion
The jQuery .ajaxComplete() method is the legacy shorthand for binding global Ajax complete handlers on document. Use $(document).ajaxComplete(handler) to register a callback — deprecated since jQuery 3.5. The handler receives (event, jqXHR, ajaxOptions) and runs after every qualifying request, success or error.
For new code, prefer $(document).on("ajaxComplete", fn) for binding and $(document).off("ajaxComplete", fn) for cleanup. When you encounter .ajaxComplete() in older projects, recognize it, understand it, and migrate when practical. Continue with the jQuery ajaxStop event tutorial to hide loading UI when all global Ajax requests finish.
Write new code with deprecated $(document).ajaxComplete(handler)
Attach global handlers to window — use document
Expect a no-arg .ajaxComplete() trigger form — it does not exist
Use .unbind("ajaxComplete") — it is also deprecated; use .off()
Assume ajaxComplete means success — it fires on error too
Summary
Key Takeaways
Knowledge Unlocked
Six things to remember about .ajaxComplete()
Legacy bind, modern migrate.
6
Core concepts
.ac01
.ajaxComplete(fn)
Bind
Deprecated
doc02
document
Bind here
Since 1.9
3×03
3 args
event, jqXHR, settings
Handler
.on04
.on("ajaxComplete")
Modern
Replace
.off05
.off()
Remove
Cleanup
3.506
Deprecated
Since 3.5
Migrate
❓ Frequently Asked Questions
The .ajaxComplete(handler) method binds a global function that runs whenever any qualifying jQuery Ajax request finishes — success or error. You must attach it to document: $(document).ajaxComplete(fn). Unlike .click(), there is no no-argument trigger form — only binding. The method has been deprecated since jQuery 3.5; use $(document).on('ajaxComplete', handler) instead.
Yes — $(document).ajaxComplete(handler) is deprecated since jQuery 3.5. Use $(document).on('ajaxComplete', 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('ajaxComplete', handler), not the deprecated .unbind() API.
ajaxComplete is a global Ajax event, not a DOM event on a specific element. Since jQuery 1.9, all global Ajax handlers — including .ajaxComplete(handler) — must be bound to document, not window or other elements. The correct legacy pattern is $(document).ajaxComplete(fn); the modern equivalent is $(document).on('ajaxComplete', fn).
The official jQuery API lists handler as Type Function(), but the callback actually receives three arguments — the same as the ajaxComplete event: function(event, jqXHR, ajaxOptions). Use jqXHR.responseText (or xhr.responseText) for the response body and ajaxOptions.url to identify which request completed.
Replace $(document).ajaxComplete(fn) with $(document).on('ajaxComplete', fn). Replace cleanup via .unbind('ajaxComplete') with $(document).off('ajaxComplete', fn). Under the hood, .ajaxComplete(handler) already delegates to .on('ajaxComplete') — migration is a straight rename with no behavior change for simple bindings.
Yes. jQuery 3.x keeps .ajaxComplete(handler) for backward compatibility with jQuery 1.x and 2.x codebases. It still binds correctly on document. The API docs mark it deprecated since 3.5 to steer new projects toward .on(). Do not use .ajaxComplete(handler) in new code — prefer the modern API covered in the jQuery ajaxComplete event tutorial.
Did you know?
Unlike DOM event shorthands such as .click(), which support both binding (.click(fn)) and triggering (no-arg .click()), .ajaxComplete() is bind-only. You cannot programmatically fire global Ajax events through a no-argument .ajaxComplete() call — they fire automatically when jQuery’s Ajax transport completes a request. The deprecated method is simply sugar for .on("ajaxComplete", fn) on document.