jQuery ajaxStart Event

Beginner
5 min read
Updated: Nov 2026
3 examples
Ajax

Definition

ajaxStart is a global AjaxEvent (event since jQuery 1.0; .on() binding since 1.7). jQuery triggers it on document when the first qualifying Ajax request is about to begin — and only if no other global requests are already active.

Syntax

Start with these common calls. Keep them short and readable.

jQuery
$(document).on("ajaxStart", function () {
  // runs when the first global Ajax request begins
});

// Order (batch):
// ajaxStart → ajaxSend → success|error → ajaxComplete → ajaxStop

// Opt out for one call:
$.ajax({ url: "/x", global: false });
CallWhat it does
documentOnly valid bind target for global Ajax events
handlerfunction() — no request args
ajaxStopHide loading when no global requests remain
global: falseSkip 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

ParameterDescription
Step 1Attach the handler to document with .on("ajaxStart", handler).
Step 2Make requests with $.ajax(), $.get(), $.post(), or .load().
Step 3Show a spinner or status text inside the handler (no jqXHR args).

Return Value

Return ValueDescription
jQuery objectMost 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 the first Ajax request begins after a click.

jQuery
$(document).on("ajaxStart", function () {
  $(".log").text("Triggered ajaxStart handler.");
});

$(".trigger").on("click", function () {
  $(".result").load("ajax/test.html");
});
Try It Yourself

How It Works

  1. Bind. .on("ajaxStart") on document listens globally.
  2. Click. .load() starts an Ajax request under the hood.
  3. First. Because nothing else is active, ajaxStart fires.

Example 2 — Show a Loading Message

Official demo: reveal a loading element whenever Ajax activity begins.

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

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

How It Works

  1. Handler. On start, write a loading message into #loading.
  2. Trigger. Any qualifying Ajax call can light up the UI.
  3. No args. You do not need jqXHR — this is page-wide UI only.

Example 3 — Parallel Requests Fire Once

Three overlapping calls still produce a single ajaxStart.

jQuery
var startCount = 0;

$(document).on("ajaxStart", function () {
  startCount++;
  $("#log").text("ajaxStart count: " + startCount);
});

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

How It Works

  1. Idle → busy. The first request finds no active globals and fires start.
  2. Already busy. The next two see activity in progress — no extra start.
  3. Count. Your counter increments once per batch, not per call.

Frequently Asked Questions

ajaxStart is a global AjaxEvent that fires when the first qualifying jQuery Ajax request is about to be sent — and only when no other global Ajax requests are already in progress. Bind it with $(document).on("ajaxStart", 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("ajaxStart", fn) and remove with $(document).off("ajaxStart", fn).
No. It fires once when the first active global request begins. Three parallel $.ajax() calls still trigger ajaxStart only once. Pair it with ajaxStop, which fires when the last active global request finishes.
ajaxStart fires once at the start of a batch (no active requests yet). ajaxSend fires before every individual qualifying request and receives event, jqXHR, and settings. Use ajaxStart for page-wide loading UI; use ajaxSend for per-request work.
When $.ajax() or $.ajaxSetup() sets global: false, that request opts out of all global Ajax events. ajaxStart will not fire for it, and it does not count toward the active global request total used by ajaxStart/ajaxStop.
None that matter for typical use — function() { … }. Unlike ajaxSend or ajaxComplete, you do not get jqXHR or settings. Use those events when you need per-request details.
The shorthand method .ajaxStart(handler) is deprecated as of jQuery 3.5. Prefer $(document).on("ajaxStart", handler) — the event API this page teaches.

Next: .ajaxStart() Method

See the deprecated shorthand and how to migrate to .on("ajaxStart").

.ajaxStart() Method tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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