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

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.

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.

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

2. Official jQuery API migration note

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

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

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

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

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

⚡ Quick Reference

GoalLegacy (.ajaxComplete)Modern replacement
Bind global complete handler$(document).ajaxComplete(fn)$(document).on("ajaxComplete", fn)
Handler signaturefunction(event, jqXHR, ajaxOptions)
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("ajaxComplete", fn)
Trigger ajaxComplete programmaticallyNot supported — no no-arg .ajaxComplete() trigger form

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

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.

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

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

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.

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

$( document ).ajaxComplete( 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 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.

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

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

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

jQuery
var count = 0;

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

$( document ).ajaxComplete( onComplete );

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

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.

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

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

Browser Support

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

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

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.

💡 Best Practices

✅ Do

  • Use $(document).on("ajaxComplete", 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("ajaxComplete", fn) on SPA teardown
  • Read the modern ajaxComplete event tutorial for full API coverage

❌ Don’t

  • 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

Key Takeaways

Knowledge Unlocked

Six things to remember about .ajaxComplete()

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("ajaxComplete")

Modern

Replace
.off 05

.off()

Remove

Cleanup
3.5 06

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.

Next: ajaxStop Event

Hide loading UI when the last global Ajax request completes — pair with ajaxStart.

ajaxStop 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