English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

The jQuery ajaxStart() method

jQuery AJAX Methods

The ajaxStart() method attaches a function to be executed when an Ajax request starts. This is an AjaxEvent.

Every time an AJAX request is about to be sent, jQuery checks if there are any other pending AJAX requests. If there are none in progress, jQuery triggers the ajaxStart event. At this point, all handlers registered with the ajaxStart() method will be executed.

Note:From jQuery 1.8Since version X, this method should only be attached to the document.

Syntax:

$(document).ajaxStart(function())

Example

Display the "Loading" icon when the AJAX request starts:

$(document).ajaxStart(function(){
  $("div").html('<i class="fa fa-spinner fa-pulse fa-5x"></i>');
});
Test See‹/›

Parameter Value

ParametersDescription
function()Specify a function to run when the AJAX request starts

jQuery AJAX Methods