jQuery ajaxSend()Method

jQuery AJAX 方法jQuery AJAX Methods

Examples

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

$(document).ajaxSend(function(e,xhr,opt){ $("div").append("<p>Requesting: " + opt.url + "</p>"); });

Try it Yourself »

Definition and Usage

The ajaxSend() method specifies a function to run when an AJAX request is about to be sent.

Note:As of jQuery version 1.8, this method is only attached to the document.


Syntax

$(document).ajaxSend(function(event,xhr,options))

Parameters Description
function(event,xhr,options) Required. Specifies the function to run when the request succeeds.
Additional parameters:
  • eventContains the event object
  • xhrContains the XMLHttpRequest object
  • optionsContains the options used in the AJAX request


jQuery AJAX 方法jQuery AJAX Methods

Other Extensions