Latest web development tutorials

jQuery ajaxSend () method

jQuery AJAX Methods jQuery AJAX Methods

Examples

When about to send AJAX requests, change the content <div> element:

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

try it"

Definition and Usage

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

Note: Since jQuery version 1.8 onwards, this method is only attached to the document.


grammar

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

参数 描述
function(event,xhr,options) 必需。规定当请求成功时运行的函数。
额外的参数:
  • event - 包含 event 对象
  • xhr - 包含 XMLHttpRequest 对象
  • options - 包含 AJAX 请求中使用的选项


jQuery AJAX Methods jQuery AJAX Methods