jQuery ajaxStop Event

Beginner
5 min read
Updated: Nov 2026
3 examples
Ajax

Definition

ajaxStop is a global AjaxEvent (since jQuery 1.0; .on() binding since 1.7). jQuery triggers it on document when the last qualifying Ajax request finishes and no others remain active. All registered handlers run.

Syntax

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

jQuery
$(document).on("ajaxStop", function () {
  // runs when no global Ajax requests remain active
});

// Batch lifecycle:
// ajaxStart (first begins)  →  …requests…  →  ajaxStop (last ends)

// Opt out for one call:
$.ajax({ url: "/x", global: false });
CallWhat it does
documentOnly valid bind target for global Ajax events
handlerfunction() — no extra arguments
ajaxStartShow loading UI when the first request begins
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("ajaxStop", handler).
Step 2Pair with ajaxStart if you show a spinner when activity begins.
Step 3Make requests with $.ajax(), $.get(), $.post(), or .load().

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 global Ajax activity ends after a click.

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

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

How It Works

  1. Bind. .on("ajaxStop") on document listens globally.
  2. Click. .load() starts an Ajax request under the hood.
  3. Idle. When that request finishes and none remain, ajaxStop fires.

Example 2 — Hide #loading

Official demo: hide a loading message when all Ajax activity ends.

jQuery
$(document).on("ajaxStop", function () {
  $("#loading").hide();
});
Try It Yourself

How It Works

  1. Role. ajaxStop is the hide hook for page-wide loading UI.
  2. Once. Parallel requests share one hide — not one per call.
  3. Pair. Use ajaxStart to show #loading when work begins.

Example 3 — Parallel Requests Fire Once

Two $.get() calls at once — ajaxStop increments only when both finish.

jQuery
var stopCount = 0;

$(document).on("ajaxStop", function () {
  stopCount++;
  $("#stop-count").text(stopCount);
});

$("#run-two").on("click", function () {
  $.get("/api/a");
  $.get("/api/b");
});

// After both finish: stopCount === 1 (not 2)
Try It Yourself

How It Works

  1. Counter. jQuery tracks active global requests internally.
  2. Overlap. The second call keeps the count above zero.
  3. Idle. When both finish, the count hits zero → one ajaxStop.

Frequently Asked Questions

ajaxStop is a global AjaxEvent that fires when all qualifying jQuery Ajax requests have completed — when no global Ajax requests remain active. Bind it with $(document).on("ajaxStop", handler) (since 1.7).
Since jQuery 1.9, all global Ajax event handlers must be bound to document — not window or other elements. Use $(document).on("ajaxStop", fn) and remove with $(document).off("ajaxStop", fn).
ajaxComplete fires after every individual qualifying request finishes. ajaxStop fires once when the last active global request completes and the active count returns to zero. For three parallel calls: ajaxComplete runs three times; ajaxStop runs once.
No. It fires only when no global Ajax requests remain in progress. Pair it with ajaxStart, which fires once when the first request begins.
When $.ajax() or $.ajaxSetup() sets global: false, that request opts out of all global Ajax events. ajaxStop will not fire for it, and it does not count toward active global requests for ajaxStart/ajaxStop.
None beyond a normal function call — function() { ... }. Unlike ajaxComplete or ajaxSend, you do not receive jqXHR or settings. Use ajaxComplete when you need per-request details.
The shorthand method .ajaxStop(handler) is deprecated as of jQuery 3.5. Prefer $(document).on("ajaxStop", handler) — the event API this page teaches.

Next: .ajaxStop() Method

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

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