jQuery ajaxComplete Event

Beginner
5 min read
Updated: Nov 2026
3 examples
Ajax

Definition

ajaxComplete is a global AjaxEvent (since jQuery 1.0; .on() binding since 1.7). jQuery triggers it on document whenever any qualifying Ajax request finishes — success or error. All registered handlers run.

Syntax

Start with these common calls. Keep them short and readable.

jQuery
$(document).on("ajaxComplete", function (event, jqXHR, ajaxOptions) {
  // runs after every qualifying Ajax request finishes
});

// Order (per request):
// ajaxSuccess | ajaxError  →  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)
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("ajaxComplete", 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 completes after a click.

jQuery
$(document).on("ajaxComplete", function () {
  $(".log").text("Triggered ajaxComplete handler.");
});

$(".trigger").on("click", function () {
  $(".result").load("ajax/test.html");
});
Try It Yourself

How It Works

  1. Bind. .on("ajaxComplete") on document listens globally.
  2. Click. .load() starts an Ajax request under the hood.
  3. Complete. When the request finishes, every ajaxComplete handler runs.

Example 2 — Filter by settings.url

Handlers run for every request — narrow them with the settings object.

jQuery
$(document).on("ajaxComplete", function (event, xhr, settings) {
  if (settings.url === "ajax/test.html") {
    $(".log").text(
      "Triggered ajaxComplete handler. The result is " +
      xhr.responseText
    );
  }
});
Try It Yourself

How It Works

  1. Args. jQuery passes event, xhr, and settings.
  2. Compare. Check settings.url against the endpoint you care about.
  3. Read. Use xhr.responseText for the raw response body.

Example 3 — Append “Request Complete.”

Official demo: append a short status string for every finished request.

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

How It Works

  1. Global. One handler covers every qualifying Ajax call.
  2. Append. Each completion adds another status fragment.
  3. Count. Parallel requests each fire their own ajaxComplete.

Frequently Asked Questions

ajaxComplete is a global AjaxEvent that fires whenever any qualifying jQuery Ajax request finishes — success or failure. Bind it with $(document).on("ajaxComplete", handler) (since 1.7). Every registered handler runs for every completed request.
Since jQuery 1.9, all global Ajax event handlers must be bound to document — not window or other elements. Use $(document).on("ajaxComplete", fn) and remove with $(document).off("ajaxComplete", fn).
Yes. It always runs after a request completes. On success it follows ajaxSuccess; on failure it follows ajaxError. Use those outcome-specific events when you only care about one result.
ajaxComplete is a global document event — one handler observes every qualifying request on the page. always() is per-request on the jqXHR from $.ajax() — it runs only for that call. Use global events for site-wide UI; use always() for request-specific cleanup.
When $.ajax() or $.ajaxSetup() sets global: false, that request opts out of all global Ajax events. ajaxComplete will not fire for it. Per-request done(), fail(), and always() still run.
Three: function(event, jqXHR, ajaxOptions). 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).
The shorthand method .ajaxComplete(handler) is deprecated as of jQuery 3.5. Prefer $(document).on("ajaxComplete", handler) — the event API this page teaches.

Next: .ajaxComplete() Method

See the deprecated shorthand and how to migrate to .on("ajaxComplete").

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