jQuery .ajaxStop() 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 .ajaxStop() method is jQuery’s legacy shorthand for binding global ajaxStop handlers on document. This tutorial covers $(document).ajaxStop(handler), the handler signature function() with no jqXHR or settings arguments, why binding must target document since 1.9, migration to .on("ajaxStop") and cleanup with .off("ajaxStop"), pairing with ajaxStart for loading UI, and why the method is deprecated since jQuery 3.5. Unlike .click(), there is no trigger variant — only binding. The handler fires when the last global Ajax request completes. For the modern ajaxStop event API, see the jQuery ajaxStop event tutorial.

01

.ajaxStop(fn)

Bind handler

02

document

Bind target

03

No args

function() only

04

Last only

Once per batch

05

.on()

Modern bind

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(), .ajaxStop(), and others. The .ajaxStop(handler) method let you register a page-wide “last request finishing” callback in one short call: $(document).ajaxStop(function(){ ... }). It has been available since jQuery 1.0 and remains in jQuery 3.x for backward compatibility but is marked deprecated since 3.5.

Understanding .ajaxStop() matters when reading older admin panels, legacy jQuery plugins, and tutorials written before .on("ajaxStop") became standard. Unlike DOM event shorthands such as .click(), .ajaxStop() has only a binding form — there is no no-argument trigger variant. The handler runs when the last qualifying global Ajax request completes — ideal for hiding a page-wide loading spinner. Modern jQuery binds the same global event explicitly: $(document).on("ajaxStop", handler). This page documents the shorthand API and shows how to migrate.

Understanding the .ajaxStop() Method

The official jQuery API describes .ajaxStop() as a way to register a handler to be executed when all Ajax requests have completed. When you pass a function, jQuery registers it on document and calls it when the last qualifying global Ajax request has finished and no others remain active. That is the same ajaxStop global event that .on("ajaxStop") handles today.

The handler receives no arguments — the API lists handler as Function() with no parameters. Unlike ajaxComplete, you do not get jqXHR or settings. Requests with global: false opt out — they do not trigger .ajaxStop() handlers. Pair with .ajaxStart() (or .on("ajaxStart")) to show loading UI when a batch begins and hide it when the last active request finishes.

⚠️
Deprecated since jQuery 3.5

Do not use $(document).ajaxStop(handler) in new code. Replace it with $(document).on("ajaxStop", handler). Remove handlers with $(document).off("ajaxStop", handler) — not .unbind("ajaxStop"). For event order, parallel requests, global: false, and comparison with ajaxComplete, read the jQuery ajaxStop event tutorial.

📝 Syntax

The .ajaxStop() method has one signature from the official jQuery API — binding only. There is no trigger form unlike .click():

1. Bind a handler — .ajaxStop( handler ) (deprecated since 3.5)

jQuery
$( document ).ajaxStop( handler )
  • handler — function invoked when the last global Ajax request completes: function() { ... } — no jqXHR or settings arguments.
  • Must attach to document since jQuery 1.9 — not window or other elements.
  • Fires only when the active global request count returns to zero.
  • Returns the jQuery object (document wrapped) for chaining.
  • Modern replacement: $( document ).on( "ajaxStop", handler ).

2. Official jQuery API migration note

jQuery
// Deprecated binding
$( document ).ajaxStop( function() {
  console.log( "All global Ajax requests completed." );
} );

// Modern binding
$( document ).on( "ajaxStop", function() {
  console.log( "All global Ajax requests completed." );
} );

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

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

jQuery
$( document ).off( "ajaxStop" );              // remove all ajaxStop handlers
$( document ).off( "ajaxStop", myHandler );   // remove one handler

Do not use deprecated .unbind("ajaxStop") in new code. Store a named function reference when you need to remove a specific handler later.

Return value

  • .ajaxStop(handler) returns the original jQuery object for chaining.
  • Handler return values are ignored by jQuery’s global Ajax event system.

⚡ Quick Reference

GoalLegacy (.ajaxStop)Modern replacement
Bind global stop handler$(document).ajaxStop(fn)$(document).on("ajaxStop", fn)
Handler signaturefunction() — no extra arguments
When it firesLast global request completes (count returns to zero)
Show spinner when batch starts$(document).on("ajaxStart", fn)
Per-request finish$(document).on("ajaxComplete", fn)
Opt out of global events$.ajax({ url: "/x", global: false })
Remove handlers$(document).off("ajaxStop", fn)
Trigger ajaxStop programmaticallyNot supported — no no-arg .ajaxStop() trigger form

📋 .ajaxStop() vs .on("ajaxStop") vs ajaxComplete

Three related APIs — know which one binds globally, which one is modern, and which one fires per request. Unlike .click(), there is no trigger shorthand.

.ajaxStop()
deprecated

Legacy bind — $(document).ajaxStop(fn) — use modern API for new code

.on("ajaxStop")
bind

Modern binding since 1.7 — same behavior, clearer intent, reliable unbinding

ajaxComplete
every call

Fires after each individual request — receives jqXHR and settings

ajaxStop event
concept

Global AjaxEvent — fires once when a batch ends; full guide on the event tutorial page

Examples Gallery

Five examples cover basic binding, a legacy loading indicator, parallel requests firing once, migration from .ajaxStop() to .on("ajaxStop"), and removing handlers with .off() paired with .ajaxStart(). Use the Try-it links to run each snippet in the browser. Remember: binding with .ajaxStop(handler) is deprecated — these demos show legacy syntax you will encounter in older code.

📚 Binding & Loading UI

Legacy .ajaxStop() patterns for page-wide Ajax activity.

Example 1 — Basic $(document).ajaxStop(fn) + Button Triggers $.get()

The canonical legacy pattern — attach a function on document that runs when the last qualifying global Ajax request has completed.

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

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

How It Works

$(document).ajaxStop(fn) registers the function on document. jQuery internally routes this to .on("ajaxStop", fn). The handler runs when the last global request completes — not after the response arrives.

Example 2 — Legacy Loading Indicator: Hide #loading

A common pattern in older codebases — hide a loading element when all global Ajax activity ends.

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

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

How It Works

ajaxStop is your global hook when all activity ends. Hide the spinner here; show it in a paired .ajaxStart() handler (or migrate both to .on()) when the batch begins.

Example 3 — Parallel Requests: ajaxStop Fires Once

Three simultaneous $.get() calls trigger ajaxStop once — not three times.

jQuery
var startCount = 0;

$( document ).ajaxStop( function() {
  startCount++;
  $( ".log" ).text( "ajaxStop fired — count: " + startCount );
} );

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

How It Works

jQuery tracks active global requests. ajaxStop fires only when the count returns to zero. Parallel calls in the same batch share ajaxStart and ajaxStop — ideal for page-wide loading UI without manual counting.

📈 Migration & Cleanup

Compare legacy and modern APIs, and remove handlers with .off().

Example 4 — Migration: .ajaxStop(fn) vs .on("ajaxStop", fn)

Both bind the same global event — .on() is the recommended API for new code.

jQuery
// Legacy — deprecated since jQuery 3.5
$( document ).ajaxStop( function() {
  $( "#out" ).text( "Legacy: .ajaxStop(function(){ ... })." );
} );

// Modern — use for new code
$( document ).on( "ajaxStop", function() {
  $( "#out" ).text( "Modern: .on('ajaxStop', function(){ ... })." );
} );
Try It Yourself

How It Works

Under the hood, .ajaxStop(fn) calls .on("ajaxStop", fn). Migration is a straight rename with no behavior change for simple bindings. The modern API also pairs cleanly with .off("ajaxStop", fn) for teardown.

Example 5 — Remove Handler with .off("ajaxStop") + Pair .ajaxStart()

Store a named function reference, pair start/stop for loading UI, then remove the stop handler with .off().

jQuery
var count = 0;

function onStart() {
  $( "#loading" ).show().text( "Loading..." );
}

function onStop() {
  count++;
  $( "#loading" ).hide();
}

$( document ).ajaxStart( onStart );
$( document ).ajaxStop( onStop );

$( "#remove" ).on( "click", function() {
  $( document ).off( "ajaxStop", onStop );
  $( "#loading" ).show().text( "Stop handler removed — count stays " + count + "." );
} );
Try It Yourself

How It Works

Anonymous functions passed to .ajaxStop() cannot be removed individually — use a named function. .off("ajaxStop", onStop) removes exactly that handler while .ajaxStart(onStart) continues to show the spinner. Do not call deprecated .unbind("ajaxStop") in new code.

🚀 Common Use Cases

  • Reading legacy code — recognize $(document).ajaxStop(fn) as equivalent to .on("ajaxStop", fn) in older admin panels.
  • Global loading spinners — legacy pages hide #loading via .ajaxStop() — migrate to .on() when refactoring.
  • Pair with ajaxStart — show UI on start, hide when the last request finishes — the classic loading-indicator pattern.
  • Parallel request batches — one ajaxStop for three simultaneous $.get() calls — no manual counter needed.
  • SPA teardown — remove global handlers with .off("ajaxStop", fn) when unmounting a view.
  • Third-party isolation — requests with global: false still opt out of .ajaxStop() handlers.

🧠 How .ajaxStop() Routes Through jQuery

1

You call .ajaxStop(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

.ajaxStop(handler) delegates internally to .on("ajaxStop", handler) — the handler is stored in jQuery’s event system on document.

.on("ajaxStop")
3

Last global request completes

When a qualifying Ajax call finishes and no other global requests remain active, jQuery triggers ajaxStop on document — unless the request used global: false.

last only
4

Handler runs with no arguments

function() — hide loading UI, re-enable navigation, or log activity. Pair with .ajaxStart() to show UI when a batch begins. Returns the jQuery object for chaining.

📝 Notes

  • Deprecated since jQuery 3.5 — do not use $(document).ajaxStop(handler) in new code. Use .on("ajaxStop") instead. Available since jQuery 1.0.
  • 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 no arguments — unlike ajaxComplete, there is no jqXHR or settings object.
  • Fires when the last global request completes — not after every individual call.
  • Remove handlers with $(document).off("ajaxStop", handler) — not .unbind("ajaxStop").
  • Requests with global: false do not trigger .ajaxStop() handlers.
  • Pair with .ajaxStart() (or .on("ajaxStart")) to show loading UI when a batch begins.
  • Legacy code using .ajaxStop() still runs in jQuery 3.x — migrate when you refactor those files.
  • For event order, parallel requests, and the complete modern workflow, see the jQuery ajaxStop event tutorial.

Browser Support

The underlying ajaxStop global event works wherever jQuery’s Ajax transport runs. The .ajaxStop() 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 .ajaxStop(handler) is deprecated since 3.5 but still functional.

jQuery 1.0+

jQuery .ajaxStop() method

Supported across all jQuery versions you are likely to maintain. Deprecated binding since 3.5 — use .on('ajaxStop') 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
.ajaxStop() Legacy API

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

Conclusion

The jQuery .ajaxStop() method is the legacy shorthand for binding global Ajax stop handlers on document. Use $(document).ajaxStop(handler) to register a callback — deprecated since jQuery 3.5. The handler is function() with no extra arguments and runs when all qualifying global requests have completed.

For new code, prefer $(document).on("ajaxStop", fn) for binding and $(document).off("ajaxStop", fn) for cleanup. Pair with ajaxStart for loading UI. When you encounter .ajaxStop() in older projects, recognize it, understand it, and migrate when practical. For the full modern ajaxStop workflow — parallel requests, global: false, and event order — continue with the jQuery ajaxStop event tutorial, then learn deferred.done() for per-request success callbacks.

💡 Best Practices

✅ Do

  • Use $(document).on("ajaxStop", handler) for all new global bindings
  • Bind on document — required since jQuery 1.9
  • Pair with ajaxStart to hide loading UI when all requests finish
  • Store named function references when you need to remove handlers later
  • Read the modern ajaxStop event tutorial for full API coverage

❌ Don’t

  • Write new code with deprecated $(document).ajaxStop(handler)
  • Attach global handlers to window — use document
  • Expect jqXHR or settings in the handler — use ajaxComplete for that
  • Expect a no-arg .ajaxStop() trigger form — it does not exist
  • Use .unbind("ajaxStop") — it is also deprecated; use .off()

Key Takeaways

Knowledge Unlocked

Six things to remember about .ajaxStop()

Legacy bind, modern migrate.

6
Core concepts
doc 02

document

Bind here

Since 1.9
03

No args

function() only

Handler
.on 04

.on("ajaxStop")

Modern

Replace
.off 05

.off()

Remove

Cleanup
3.5 06

Deprecated

Since 3.5

Migrate

❓ Frequently Asked Questions

The .ajaxStop(handler) method binds a global function that runs when all qualifying jQuery Ajax requests have completed — when no global requests remain active. You must attach it to document: $(document).ajaxStop(fn). Unlike .click(), there is no no-argument trigger form — only binding. The method has been deprecated since jQuery 3.5; use $(document).on('ajaxStop', handler) instead.
Yes — $(document).ajaxStop(handler) is deprecated since jQuery 3.5 (available since jQuery 1.0). Use $(document).on('ajaxStop', 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('ajaxStop', handler), not the deprecated .unbind() API.
ajaxStop is a global Ajax event, not a DOM event on a specific element. Since jQuery 1.9, all global Ajax handlers — including .ajaxStop(handler) — must be bound to document, not window or other elements. The correct legacy pattern is $(document).ajaxStop(fn); the modern equivalent is $(document).on('ajaxStop', fn).
None. The official jQuery API lists handler as Type Function() with no parameters. Unlike ajaxComplete, the callback is simply function() { ... } — you do not receive event, jqXHR, or ajaxOptions. For per-request details, use ajaxComplete instead.
Replace $(document).ajaxStop(fn) with $(document).on('ajaxStop', fn). Replace cleanup via .unbind('ajaxStop') with $(document).off('ajaxStop', fn). Under the hood, .ajaxStop(handler) already delegates to .on('ajaxStop') — migration is a straight rename with no behavior change for simple bindings.
.ajaxStop() fires once when the last global request finishes — ideal for hiding page-wide loading spinners. ajaxComplete fires after every individual request and receives (event, jqXHR, ajaxOptions). Pair .ajaxStop() with .ajaxStart() (or their .on() equivalents) to show and hide loading UI when a batch begins and ends.
Did you know?

Unlike DOM event shorthands such as .click(), which support both binding (.click(fn)) and triggering (no-arg .click()), .ajaxStop() is bind-only. You cannot programmatically fire global Ajax events through a no-argument .ajaxStop() call — they fire automatically when jQuery’s Ajax transport completes the last global request. The deprecated method is simply sugar for .on("ajaxStop", fn) on document. Three parallel $.get() calls trigger ajaxStart once and ajaxStop once — not three times each.

Next: deferred.done() Method

Handle successful Ajax responses with per-request done() callbacks.

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