jQuery ajax - ajaxSend() method

Example

Change the content of the div element when the AJAX request is about to be sent:

$("div").ajaxSend(function(e,xhr,opt){
  $(this).html("Requesting " + opt.url);
);

Try it yourself

Definition and usage

The ajaxSend() method executes a function when the AJAX request starts. It is an Ajax event.

Syntax

.ajaxSend([function(event,xhr,options)])
Parameters Description
function(event,xhr,options)

Required. Specifies the function to be executed when the request starts.

Additional parameters:

  • event - Contains event object
  • xhr - Contains XMLHttpRequest object
  • options - Contains options used in AJAX requests

Detailed description

XMLHttpRequest object and settings passed as parameters to the callback function.