.ajaxComplete(handler) is jQuery’s legacy shorthand (since 1.0) for binding a global Ajax “request finished” handler on document. It runs after every qualifying request — success or error. Internally it is sugar for .on("ajaxComplete", handler).
Syntax
Start with these common calls. Keep them short and readable.
jQuery
// Deprecated (since 3.5)
$(document).ajaxComplete(function (event, jqXHR, ajaxOptions) {
// runs after every qualifying Ajax request finishes
});
// Modern replacement
$(document).on("ajaxComplete", handler);
// Bind only — no no-arg .ajaxComplete() trigger form
// Opt out: $.ajax({ url: "/x", global: false })
Call
What it does
document
Only valid bind target for global Ajax events
handler
function(event, jqXHR, ajaxOptions)
ajaxOptions.url
Filter which requests you react to
global: false
Skip 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
Parameter
Description
Step 1
Attach the handler to document with .ajaxComplete(handler) (legacy) or .on("ajaxComplete", handler) (preferred).
Step 2
Make requests with $.ajax(), $.get(), $.post(), or .load().
Step 3
Optionally filter with ajaxOptions.url and read jqXHR.responseText.
Return Value
Return Value
Description
jQuery object
Most setters and traversing helpers return the jQuery collection so you can chain more methods.
jQuery Examples
Example 1 — Basic $(document).ajaxComplete(fn)
Canonical legacy pattern: log when any Ajax request completes after a click.
jQuery
$(document).ajaxComplete(function () {
$(".log").text("Handler ran via .ajaxComplete(function(){ ... }).");
});
$("#fetch").on("click", function () {
$.get("https://jsonplaceholder.typicode.com/posts/1");
});
Each finished request →
#msg gains " Request Complete. "
Three parallel calls → three appends
How It Works
Global. One handler covers every qualifying Ajax call.
Append. Each completion adds another status fragment.
Count. Parallel requests each fire their own complete event.
Frequently Asked Questions
The .ajaxComplete(handler) method binds a global function that runs whenever any qualifying jQuery Ajax request finishes — success or error. Attach it to document: $(document).ajaxComplete(fn). It is bind-only (no trigger form). Deprecated since jQuery 3.5; use $(document).on("ajaxComplete", handler) instead.
Yes. $(document).ajaxComplete(handler) has been deprecated since jQuery 3.5 (available since 1.0). Prefer $(document).on("ajaxComplete", handler) for new code. Legacy bindings still work in jQuery 3.x; migrate when you touch those files. Remove handlers with $(document).off("ajaxComplete", handler).
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 bind to document. Correct legacy form: $(document).ajaxComplete(fn). Modern form: $(document).on("ajaxComplete", fn).
The API lists handler as Function(), but the callback receives three arguments — the same as the ajaxComplete event: function(event, jqXHR, ajaxOptions). Use jqXHR.responseText for the body and ajaxOptions.url to identify the request.
Replace $(document).ajaxComplete(fn) with $(document).on("ajaxComplete", fn). Use $(document).off("ajaxComplete", fn) for cleanup instead of .unbind(). Under the hood, .ajaxComplete(handler) already delegates to .on("ajaxComplete") — migration is a straight rename for simple bindings.
Yes. jQuery 3.x keeps .ajaxComplete(handler) for backward compatibility. It still binds correctly on document. Docs mark it deprecated since 3.5 to steer new projects toward .on(). Prefer the modern API covered in the jQuery ajaxComplete event tutorial.