jQuery ajaxStop Event

Beginner
7 min read
Updated: Oct 2026
5 examples
Live preview

What Is ajaxStop?

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.

Remember
$(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 });
NeedUse
Hide loading when idle$(document).on("ajaxStop", fn)
Show loading when busyajaxStart
Every finished requestajaxComplete
One request only$.ajax(...).always(fn)
Silent background callglobal: false

How to Use ajaxStop

Bind once on document, then hide UI when global Ajax activity ends.

  1. Attach the handler to document with .on("ajaxStop", handler).
  2. Pair with ajaxStart if you show a spinner when activity begins.
  3. Make requests with $.ajax(), $.get(), $.post(), or .load().
  4. Remember: the handler has no jqXHR / settings args.
  5. Use global: false on requests that must stay silent.
PieceRequired?Role
documentYes (1.9+)Only valid bind target for global Ajax events
handlerYesfunction() — no extra arguments
ajaxStartRecommendedShow loading UI when the first request begins
global: falseOptionalSkip all global Ajax events for that call

Pseudocode

Pseudocode
bind ajaxStop on document with handler()

when a jQuery Ajax request finishes:
    if request.global === false:
        do not count it / do not fire ajaxStop for it
        return

    decrement active global request count

    fire ajaxComplete for this request

    if active global request count === 0:
        fire ajaxStop
            for each registered handler:
                call handler()

Cheat Sheet

Keep these facts handy while wiring global loading UI.

TopicDetail
Bind$(document).on("ajaxStop", handler)
Unbind$(document).off("ajaxStop" [, handler])
Signaturefunction() — no jqXHR / settings
WhenLast global request ends (active count → 0)
SinceEvent 1.0 · .on() form 1.7 · document-only 1.9+
Pair with$(document).on("ajaxStart", fn)
Also fires ifLast request cancelled via beforeSend → false
Opt outglobal: false in $.ajax() / $.ajaxSetup()

Live Preview

Run real requests and watch ajaxStart / ajaxStop update the status once per batch.

Live demo uses a public JSON API. Needs network access.

Result
Ready — pick an action and click Run.

jQuery Examples

Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.

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.
  4. Update. The log text confirms the global event fired.

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.
  4. Keep light. Only toggle visibility — avoid heavy work here.

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.
  4. Choose. Need every finish? Use ajaxComplete instead.

Example 4 — Opt Out with global: false

Private requests skip all global Ajax events, including ajaxStop.

jQuery
$(document).on("ajaxStop", function () {
  $("#log").append(" ajaxStop");
});

// Fires ajaxStop (when idle)
$.get("/api/public");

// Does NOT fire ajaxStop
$.ajax({ url: "/api/silent", global: false });
Try It Yourself

How It Works

  1. Default. Ajax calls participate in global events.
  2. Opt out. global: false skips ajaxStop (and the other globals).
  3. Count. Private calls do not count toward the active batch.
  4. When. Use for silent prefetch, polling, or third-party widgets.

Example 5 — Pair ajaxStart + ajaxStop

Show a spinner when activity begins; hide it when the last request finishes.

jQuery
$(document).on("ajaxStart", function () {
  $("#loading").show();
});

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

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

How It Works

  1. Start. First global request → ajaxStart shows the spinner.
  2. Overlap. More requests keep the spinner visible.
  3. Stop. Last request ends → ajaxStop hides it.
  4. No counting. jQuery tracks the active count for you.

Edge Cases & Pitfalls

Check these before relying on global loading handlers in production.

target

Bind on document only (1.9+)

Handlers on window or other elements will not receive global Ajax events.

scope

Not every request

ajaxStop fires once per idle batch. Use ajaxComplete when you need a hook after each call.

args

No jqXHR / settings

The handler is function(). Read response details from ajaxComplete instead.

global

global: false stays silent

Those requests never trigger ajaxStop and do not keep your spinner open.

Browser Support

ajaxStop has been part of jQuery since 1.0. Prefer $(document).on("ajaxStop", …) (1.7+). Since 1.9, handlers must attach to document.

✓ Stable · jQuery 1.0+

jQuery ajaxStop

Works in every browser that runs your loaded jQuery version. Prefer a current jQuery 3.x build for modern projects.

100% jQuery Ajax event
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
ajaxStop Universal

Bottom line: Safe for everyday apps. Bind on document, pair with ajaxStart for spinners, and use global: false for silent background calls.

Performance Notes

ApproachCostBest for
One light ajaxStop (toggle UI)CheapPage-wide loading spinner
ajaxStart + ajaxStop pairCheapShow / hide loading for a batch
Heavy DOM work on every stopExpensiveAvoid — keep the handler tiny

Global handlers are fine when they stay light. Toggle visibility only, and prefer ajaxComplete or .always() for per-request work.

Key Takeaways

  • Role: global “all Ajax finished” hook — hide loading UI.
  • Bind: $(document).on("ajaxStop", fn) — document only since 1.9.
  • Pair: show on ajaxStart, hide on ajaxStop.
  • Per request: use ajaxComplete when you need jqXHR / settings.

One line: ajaxStop is jQuery’s global “batch idle” Ajax event — bind it on document.

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

9 people found this page helpful