The .ajaxStart() method is jQuery’s legacy shorthand for binding global ajaxStart handlers on document. This tutorial covers $(document).ajaxStart(handler), the handler signature function() with no jqXHR or settings arguments, why binding must target document since 1.9, migration to .on("ajaxStart") and cleanup with .off("ajaxStart"), pairing with ajaxStop 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 first global Ajax request begins. For the modern ajaxStart event API, see the jQuery ajaxStart event tutorial.
01
.ajaxStart(fn)
Bind handler
02
document
Bind target
03
No args
function() only
04
First only
Not every call
05
.on()
Modern bind
06
Deprecated
Since 3.5
Fundamentals
Introduction
Before jQuery 1.7 unified events with .on() and .off(), global Ajax events had matching shorthand methods — .ajaxStart(), .ajaxSend(), .ajaxComplete(), and others. The .ajaxStart(handler) method let you register a page-wide “first request beginning” callback in one short call: $(document).ajaxStart(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 .ajaxStart() matters when reading older admin panels, legacy jQuery plugins, and tutorials written before .on("ajaxStart") became standard. Unlike DOM event shorthands such as .click(), .ajaxStart() has only a binding form — there is no no-argument trigger variant. The handler runs when the first qualifying global Ajax request is about to begin — ideal for showing a page-wide loading spinner. Modern jQuery binds the same global event explicitly: $(document).on("ajaxStart", handler). This page documents the shorthand API and shows how to migrate.
Concept
Understanding the .ajaxStart() Method
The official jQuery API describes .ajaxStart() as a way to register a handler to be executed when the first Ajax request begins. When you pass a function, jQuery registers it on document and calls it when the first qualifying global Ajax request is about to start and no others are already in progress. That is the same ajaxStart global event that .on("ajaxStart") handles today.
The handler receives no arguments — the API lists handler as Function() with no parameters. Unlike ajaxSend, you do not get jqXHR or settings. Requests with global: false opt out — they do not trigger .ajaxStart() handlers. Pair with .ajaxStop() (or .on("ajaxStop")) to hide loading UI when the last active request finishes.
⚠️
Deprecated since jQuery 3.5
Do not use $(document).ajaxStart(handler) in new code. Replace it with $(document).on("ajaxStart", handler). Remove handlers with $(document).off("ajaxStart", handler) — not .unbind("ajaxStart"). For event order, parallel requests, global: false, and comparison with ajaxSend, read the jQuery ajaxStart event tutorial.
Foundation
📝 Syntax
The .ajaxStart() method has one signature from the official jQuery API — binding only. There is no trigger form unlike .click():
1. Bind a handler — .ajaxStart( handler ) (deprecated since 3.5)
jQuery
$( document ).ajaxStart( handler )
handler — function invoked when the first global Ajax request begins: function() { ... } — no jqXHR or settings arguments.
Must attach to document since jQuery 1.9 — not window or other elements.
Fires only when no other global requests are already in progress.
Returns the jQuery object (document wrapped) for chaining.
Modern replacement:$( document ).on( "ajaxStart", handler ).
2. Official jQuery API migration note
jQuery
// Deprecated binding
$( document ).ajaxStart( function() {
console.log( "First global Ajax request beginning." );
} );
// Modern binding
$( document ).on( "ajaxStart", function() {
console.log( "First global Ajax request beginning." );
} );
// Remove handler — use .off(), not .unbind()
$( document ).off( "ajaxStart", myHandler );
$( document ).off( "ajaxStart" ); // remove all ajaxStart handlers
$( document ).off( "ajaxStart", myHandler ); // remove one handler
Do not use deprecated .unbind("ajaxStart") in new code. Store a named function reference when you need to remove a specific handler later.
Return value
.ajaxStart(handler) returns the original jQuery object for chaining.
Handler return values are ignored by jQuery’s global Ajax event system.
Cheat Sheet
⚡ Quick Reference
Goal
Legacy (.ajaxStart)
Modern replacement
Bind global start handler
$(document).ajaxStart(fn) ⚠
$(document).on("ajaxStart", fn)
Handler signature
function() — no extra arguments
When it fires
First global request begins (none already active)
Hide spinner when done
$(document).on("ajaxStop", fn)
Per-request hook
$(document).on("ajaxSend", fn)
Opt out of global events
$.ajax({ url: "/x", global: false })
Remove handlers
$(document).off("ajaxStart", fn)
Trigger ajaxStart programmatically
Not supported — no no-arg .ajaxStart() trigger form
Compare
📋 .ajaxStart() vs .on("ajaxStart") vs ajaxSend
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.
.ajaxStart()
deprecated
Legacy bind — $(document).ajaxStart(fn) — use modern API for new code
.on("ajaxStart")
bind
Modern binding since 1.7 — same behavior, clearer intent, reliable unbinding
ajaxSend
every call
Fires before each individual request — receives jqXHR and settings
ajaxStart event
concept
Global AjaxEvent — fires once at batch start; full guide on the event tutorial page
Hands-On
Examples Gallery
Five examples cover basic binding, a legacy loading indicator, parallel requests firing once, migration from .ajaxStart() to .on("ajaxStart"), and removing handlers with .off() paired with .ajaxStop(). Use the Try-it links to run each snippet in the browser. Remember: binding with .ajaxStart(handler) is deprecated — these demos show legacy syntax you will encounter in older code.
📚 Binding & Loading UI
Legacy .ajaxStart() patterns for page-wide Ajax activity.
Example 1 — Basic $(document).ajaxStart(fn) + Button Triggers $.get()
The canonical legacy pattern — attach a function on document that runs when the first qualifying Ajax request is about to begin.
User clicks #fetch → ajaxStart fires when first request begins
.log shows handler message immediately when activity starts
Works for $.ajax(), $.get(), $.post(), and .load()
Deprecated — prefer .on("ajaxStart", fn) for new code
How It Works
$(document).ajaxStart(fn) registers the function on document. jQuery internally routes this to .on("ajaxStart", fn). The handler runs when the first global request begins — not after the response arrives.
Example 2 — Legacy Loading Indicator: Show #loading
A common pattern in older codebases — reveal a loading element when global Ajax activity begins.
Click Fetch → #loading becomes visible immediately
When response arrives → hide with .ajaxStop() in a paired handler
Pair .ajaxStart() with .ajaxStop() for simple global spinners
How It Works
ajaxStart is your earliest global hook when activity begins. Show the spinner here; hide it in a paired .ajaxStop() handler (or migrate both to .on()) when the last request finishes.
Example 3 — Parallel Requests: ajaxStart Fires Once
Three simultaneous $.get() calls trigger ajaxStart once — not three times.
Click Parallel → three $.get() calls start together
ajaxStart fires once — startCount increments by 1 only
Second click while idle → count goes to 2 (one ajaxStart per batch)
How It Works
jQuery tracks active global requests. ajaxStart fires only when the count goes from zero to one. Parallel calls in the same batch share one ajaxStart and one 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: .ajaxStart(fn) vs .on("ajaxStart", fn)
Both bind the same global event — .on() is the recommended API for new code.
jQuery
// Legacy — deprecated since jQuery 3.5
$( document ).ajaxStart( function() {
$( "#out" ).text( "Legacy: .ajaxStart(function(){ ... })." );
} );
// Modern — use for new code
$( document ).on( "ajaxStart", function() {
$( "#out" ).text( "Modern: .on('ajaxStart', function(){ ... })." );
} );
Both handlers fire when $.get() starts the batch
Legacy message from .ajaxStart(fn)
Modern message from .on("ajaxStart", fn)
Behavior is identical — only the API name differs
How It Works
Under the hood, .ajaxStart(fn) calls .on("ajaxStart", fn). Migration is a straight rename with no behavior change for simple bindings. The modern API also pairs cleanly with .off("ajaxStart", fn) for teardown.
Example 5 — Remove Handler with .off("ajaxStart") + Pair .ajaxStop()
Store a named function reference, pair start/stop for loading UI, then remove the start handler with .off().
Run $.get() → #loading shows, count increments
When all requests finish → .ajaxStop() hides #loading
Click Remove → .off("ajaxStart", onStart)
Next $.get() starts but onStart no longer runs — count unchanged
How It Works
Anonymous functions passed to .ajaxStart() cannot be removed individually — use a named function. .off("ajaxStart", onStart) removes exactly that handler while .ajaxStop(onStop) continues to hide the spinner. Do not call deprecated .unbind("ajaxStart") in new code.
Applications
🚀 Common Use Cases
Reading legacy code — recognize $(document).ajaxStart(fn) as equivalent to .on("ajaxStart", fn) in older admin panels.
Global loading spinners — legacy pages show #loading via .ajaxStart() — migrate to .on() when refactoring.
Pair with ajaxStop — show UI on start, hide when the last request finishes — the classic loading-indicator pattern.
Parallel request batches — one ajaxStart for three simultaneous $.get() calls — no manual counter needed.
SPA teardown — remove global handlers with .off("ajaxStart", fn) when unmounting a view.
Third-party isolation — requests with global: false still opt out of .ajaxStart() handlers.
🧠 How .ajaxStart() Routes Through jQuery
1
You call .ajaxStart(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
.ajaxStart(handler) delegates internally to .on("ajaxStart", handler) — the handler is stored in jQuery’s event system on document.
.on("ajaxStart")
3
First global request begins
When a qualifying Ajax call is about to start and no other global requests are active, jQuery triggers ajaxStart on document — unless the request used global: false.
first only
4
👉
Handler runs with no arguments
function() — show loading UI, disable navigation, or log activity. Pair with .ajaxStop() to hide UI when all requests finish. Returns the jQuery object for chaining.
Important
📝 Notes
Deprecated since jQuery 3.5 — do not use $(document).ajaxStart(handler) in new code. Use .on("ajaxStart") 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 ajaxSend, there is no jqXHR or settings object.
Fires when the first global request begins — not before every individual call.
Remove handlers with $(document).off("ajaxStart", handler) — not .unbind("ajaxStart").
Requests with global: false do not trigger .ajaxStart() handlers.
Pair with .ajaxStop() (or .on("ajaxStop")) to hide loading UI when all activity finishes.
Legacy code using .ajaxStart() still runs in jQuery 3.x — migrate when you refactor those files.
The underlying ajaxStart global event works wherever jQuery’s Ajax transport runs. The .ajaxStart() 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 .ajaxStart(handler) is deprecated since 3.5 but still functional.
✓ jQuery 1.0+
jQuery .ajaxStart() method
Supported across all jQuery versions you are likely to maintain. Deprecated binding since 3.5 — use .on('ajaxStart') for new projects. Requires jQuery Ajax — fetch() and axios do not trigger jQuery global events.
100%With jQuery Ajax
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
.ajaxStart()Legacy API
Bottom line: Safe in legacy jQuery projects. Migrate bindings to .on('ajaxStart') and cleanup to .off('ajaxStart') when updating code.
Wrap Up
Conclusion
The jQuery .ajaxStart() method is the legacy shorthand for binding global Ajax start handlers on document. Use $(document).ajaxStart(handler) to register a callback — deprecated since jQuery 3.5. The handler is function() with no extra arguments and runs when the first qualifying global request begins.
For new code, prefer $(document).on("ajaxStart", fn) for binding and $(document).off("ajaxStart", fn) for cleanup. Pair with ajaxStop for loading UI. When you encounter .ajaxStart() in older projects, recognize it, understand it, and migrate when practical. For the full modern ajaxStart workflow — parallel requests, global: false, and event order — continue with the jQuery ajaxStart event tutorial, then learn ajaxSend for the per-request hook.
Write new code with deprecated $(document).ajaxStart(handler)
Attach global handlers to window — use document
Expect jqXHR or settings in the handler — use ajaxSend for that
Expect a no-arg .ajaxStart() trigger form — it does not exist
Use .unbind("ajaxStart") — it is also deprecated; use .off()
Summary
Key Takeaways
Knowledge Unlocked
Six things to remember about .ajaxStart()
Legacy bind, modern migrate.
6
Core concepts
.as01
.ajaxStart(fn)
Bind
Deprecated
doc02
document
Bind here
Since 1.9
0×03
No args
function() only
Handler
.on04
.on("ajaxStart")
Modern
Replace
.off05
.off()
Remove
Cleanup
3.506
Deprecated
Since 3.5
Migrate
❓ Frequently Asked Questions
The .ajaxStart(handler) method binds a global function that runs when the first qualifying jQuery Ajax request is about to begin — and only when no other global requests are already in progress. You must attach it to document: $(document).ajaxStart(fn). Unlike .click(), there is no no-argument trigger form — only binding. The method has been deprecated since jQuery 3.5; use $(document).on('ajaxStart', handler) instead.
Yes — $(document).ajaxStart(handler) is deprecated since jQuery 3.5 (available since jQuery 1.0). Use $(document).on('ajaxStart', 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('ajaxStart', handler), not the deprecated .unbind() API.
ajaxStart is a global Ajax event, not a DOM event on a specific element. Since jQuery 1.9, all global Ajax handlers — including .ajaxStart(handler) — must be bound to document, not window or other elements. The correct legacy pattern is $(document).ajaxStart(fn); the modern equivalent is $(document).on('ajaxStart', fn).
None. The official jQuery API lists handler as Type Function() with no parameters. Unlike ajaxSend, the callback is simply function() { ... } — you do not receive event, jqXHR, or ajaxOptions. For per-request details, use ajaxSend instead.
Replace $(document).ajaxStart(fn) with $(document).on('ajaxStart', fn). Replace cleanup via .unbind('ajaxStart') with $(document).off('ajaxStart', fn). Under the hood, .ajaxStart(handler) already delegates to .on('ajaxStart') — migration is a straight rename with no behavior change for simple bindings.
.ajaxStart() fires once when the first global request begins — ideal for page-wide loading spinners. ajaxSend fires before every individual request and receives (event, jqXHR, ajaxOptions). Pair .ajaxStart() with .ajaxStop() (or their .on() equivalents) to show and hide loading UI when all activity finishes.
Did you know?
Unlike DOM event shorthands such as .click(), which support both binding (.click(fn)) and triggering (no-arg .click()), .ajaxStart() is bind-only. You cannot programmatically fire global Ajax events through a no-argument .ajaxStart() call — they fire automatically when jQuery’s Ajax transport begins the first global request. The deprecated method is simply sugar for .on("ajaxStart", fn) on document. Three parallel $.get() calls trigger ajaxStart once and ajaxStop once — not three times each.