.ajaxSend(handler) is jQuery’s legacy shorthand (since 1.0) for binding a global Ajax “about to send” handler on document. It runs just before every qualifying request leaves the browser. Internally it is sugar for .on("ajaxSend", handler).
Remember
// Deprecated (since 3.5)
$(document).ajaxSend(function (event, jqXHR, ajaxOptions) {
// runs just before every qualifying Ajax request is sent
});
// Modern replacement
$(document).on("ajaxSend", handler);
// Bind only — no no-arg .ajaxSend() trigger form
// Opt out: $.ajax({ url: "/x", global: false })
Recognize the legacy call, know its three handler arguments, and migrate to .on() / .off().
Attach the handler to document with .ajaxSend(handler) (legacy) or .on("ajaxSend", handler) (preferred).
Make requests with $.ajax(), $.get(), $.post(), or .load().
Optionally filter with ajaxOptions.url (response is not available yet).
Remove with .off("ajaxSend", handler) — not .unbind().
Use global: false on requests that must stay silent.
Piece
Required?
Role
document
Yes (1.9+)
Only valid bind target for global Ajax events
handler
Yes
function(event, jqXHR, ajaxOptions)
ajaxOptions.url
Optional
Filter which requests you react to
global: false
Optional
Skip all global Ajax events for that call
Pseudocode
Pseudocode
call $(document).ajaxSend(handler)
→ internally: $(document).on("ajaxSend", handler)
when a jQuery Ajax request is about to be sent:
if request.global === false:
do not fire ajaxSend
return
fire ajaxSend
for each registered handler:
call handler(event, jqXHR, ajaxOptions)
send the HTTP request
// response is not available yet
to migrate:
replace .ajaxSend(fn) with .on("ajaxSend", fn)
remove with .off("ajaxSend", fn)
Reference
Cheat Sheet
Quick map from legacy shorthand to modern APIs.
Topic
Detail
Legacy bind
$(document).ajaxSend(handler) ⚠ deprecated 3.5
Modern bind
$(document).on("ajaxSend", handler)
Unbind
$(document).off("ajaxSend" [, handler])
Signature
function(event, jqXHR, ajaxOptions)
When
Just before each qualifying request is sent
Since
Method 1.0 · document-only 1.9+ · deprecated 3.5
Trigger form
None — bind only (unlike .click())
Opt out
global: false in $.ajax() / $.ajaxSetup()
Try it
Live Preview
Run a real $.get() and watch the legacy .ajaxSend() handler update the log before the request leaves.
Demo uses deprecated .ajaxSend() plus a public JSON API. Needs network access.
Result
Ready — pick an action and click Run.
Code
jQuery Examples
Short, copy-ready snippets using the legacy shorthand. Prefer .on("ajaxSend") for new projects.
Example 1 — Basic $(document).ajaxSend(fn)
Canonical legacy pattern: log when any Ajax request is about to be sent after a click.
jQuery
$(document).ajaxSend(function () {
$(".log").text("Handler ran via .ajaxSend(function(){ ... }).");
});
$("#fetch").on("click", function () {
$.get("https://jsonplaceholder.typicode.com/posts/1");
});
Run $.get() → count increments
Click Remove → .off("ajaxSend", onSend)
Next $.get() → handler no longer runs
How It Works
Named fn. Anonymous handlers cannot be removed individually.
Bind..ajaxSend(onSend) stores that reference.
Remove..off("ajaxSend", onSend) detaches exactly that handler.
Avoid. Do not use deprecated .unbind("ajaxSend") in new code.
Edge Cases & Pitfalls
Watch for these when reading or migrating legacy Ajax code.
deprecated
Do not use in new code
.ajaxSend(handler) is deprecated since 3.5. Prefer .on("ajaxSend").
target
Bind on document only (1.9+)
Handlers on window or other elements will not receive global Ajax events.
trigger
No no-arg trigger form
Unlike .click(), calling .ajaxSend() with no arguments does not fire the event.
timing
No response yet
.ajaxSend() runs before the HTTP call. Do not read responseText here — use ajaxComplete.
Compatibility
Browser Support
The .ajaxSend() method has been part of jQuery since 1.0. Since 1.9, handlers must attach to document. Binding via .ajaxSend(handler) is deprecated since 3.5 but still functional in jQuery 3.x.
✓ Deprecated · jQuery 1.0+
jQuery .ajaxSend()
Works wherever your loaded jQuery version runs Ajax. Prefer .on('ajaxSend') for new projects. 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
.ajaxSend()Legacy API
Bottom line: Safe in legacy jQuery projects. Migrate bindings to .on('ajaxSend') and cleanup to .off('ajaxSend') when updating code.
Analysis
Performance Notes
Approach
Cost
Best for
One filtered global handler
Cheap
Site-wide outbound logging
Per-request beforeSend
Cheap
Setup for a single call
Heavy DOM work every send
Expensive
Avoid — filter or debounce
Legacy and modern binds have the same cost. Keep handlers light, filter by URL before touching the DOM, and prefer beforeSend for request-specific work.
Remember
Key Takeaways
Role: legacy global “about to send” bind — before the HTTP call.
Migrate:$(document).on("ajaxSend", fn) — preferred since 3.5.
Args:function(event, jqXHR, ajaxOptions) — filter with ajaxOptions.url.
Cleanup: use .off("ajaxSend", fn) — not .unbind().
One line:.ajaxSend() is deprecated sugar for .on("ajaxSend") on document.
Frequently Asked Questions
The .ajaxSend(handler) method binds a global function that runs just before any qualifying jQuery Ajax request is sent. Attach it to document: $(document).ajaxSend(fn). It is bind-only (no trigger form). Deprecated since jQuery 3.5; use $(document).on("ajaxSend", handler) instead.
Yes. $(document).ajaxSend(handler) has been deprecated since jQuery 3.5 (available since 1.0). Prefer $(document).on("ajaxSend", handler) for new code. Legacy bindings still work in jQuery 3.x; migrate when you touch those files. Remove handlers with $(document).off("ajaxSend", handler).
ajaxSend is a global Ajax event, not a DOM event on a specific element. Since jQuery 1.9, all global Ajax handlers — including .ajaxSend(handler) — must bind to document. Correct legacy form: $(document).ajaxSend(fn). Modern form: $(document).on("ajaxSend", fn).
The API lists handler as Function(), but the callback receives three arguments — the same as the ajaxSend event: function(event, jqXHR, ajaxOptions). Use ajaxOptions.url to identify the request. The response is not available yet.
Replace $(document).ajaxSend(fn) with $(document).on("ajaxSend", fn). Use $(document).off("ajaxSend", fn) for cleanup instead of .unbind(). Under the hood, .ajaxSend(handler) already delegates to .on("ajaxSend") — migration is a straight rename for simple bindings.
Yes. jQuery 3.x keeps .ajaxSend(handler) for backward compatibility. It still binds correctly on document. Docs mark it deprecated since 3.5 to steer new projects toward .on(). Prefer the modern API covered in the jQuery ajaxSend event tutorial.