ajaxSend is a global AjaxEvent (since jQuery 1.0; .on() binding since 1.7). jQuery triggers it on document just before any qualifying Ajax request is sent. All registered handlers run.
Syntax
Start with these common calls. Keep them short and readable.
jQuery
$(document).on("ajaxSend", function (event, jqXHR, ajaxOptions) {
// runs just before every qualifying Ajax request is sent
});
// Order (per request):
// ajaxStart → ajaxSend → (response) → ajaxSuccess|ajaxError → ajaxComplete
// Opt out for one call:
$.ajax({ url: "/x", global: false });
Call
What it does
document
Only valid bind target for global Ajax events
handler
function(event, jqXHR, ajaxOptions)
ajaxOptions.url
Filter which requests you react to
global: false
Skip 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
Parameter
Description
Step 1
Attach the handler to document with .on("ajaxSend", handler).
Step 2
Make requests with $.ajax(), $.get(), $.post(), or .load().
Step 3
Optionally filter with ajaxOptions.url (or other settings).
Return Value
Return Value
Description
jQuery object
Most 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 any Ajax request is about to be sent after a click.
jQuery
$(document).on("ajaxSend", function () {
$(".log").text("Triggered ajaxSend handler.");
});
$(".trigger").on("click", function () {
$(".result").load("ajax/test.html");
});
Each outgoing request →
#msg gains " Starting request at URL "
Three parallel calls → three appends before responses
How It Works
Global. One handler covers every qualifying Ajax call.
Append. Each send adds another status fragment with the URL.
Count. Parallel requests each fire their own ajaxSend.
Frequently Asked Questions
ajaxSend is a global AjaxEvent that fires just before any qualifying jQuery Ajax request is sent. Bind it with $(document).on("ajaxSend", handler) (since 1.7). Every registered handler runs for every outgoing request.
Since jQuery 1.9, all global Ajax event handlers must be bound to document — not window or other elements. Use $(document).on("ajaxSend", fn) and remove with $(document).off("ajaxSend", fn).
ajaxSend fires before the request leaves the browser. ajaxComplete fires after it finishes (success or error). Order: ajaxStart → ajaxSend → (response) → ajaxSuccess|ajaxError → ajaxComplete → ajaxStop.
ajaxSend is a global document event — one handler observes every qualifying request. beforeSend is a per-request $.ajax() option — it runs only for that call. Use ajaxSend for site-wide logging; use beforeSend for one-call setup (and to cancel by returning false).
When $.ajax() or $.ajaxSetup() sets global: false, that request opts out of all global Ajax events. ajaxSend will not fire for it. Per-request beforeSend, done(), fail(), and always() still run.
Three: function(event, jqXHR, ajaxOptions). event is the jQuery event; jqXHR is the request object; ajaxOptions is the settings used to create the request (filter with ajaxOptions.url). The response is not available yet.
The shorthand method .ajaxSend(handler) is deprecated as of jQuery 3.5. Prefer $(document).on("ajaxSend", handler) — the event API this page teaches.