jQuery ajaxSend() 方法
实例
当 AJAX 请求即将发送时,更改 <div> 元素的内容:
<!DOCTYPE html><html><head><script src="https://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script><script>$(document).ready(function(){$(document).ajaxSend(function(e, xhr, opt){$("div").append("<p>Requesting " + opt.url + "</p>");});$("button").click(function(){$("div").load("/example/ajax/demo_load.ashx");});});</script></head><body><div><h2>让 AJAX 更改此文本</h2></div><button>更改内容</button></body></html>
定义与用法
ajaxSend() 方法指定将要发送 AJAX 请求时要运行的函数。
注意:从 jQuery 1.8 版开始,此方法只应附加到文档。
语法
$(document).ajaxSend(function(event,xhr,options))
| 参数 | 描述 |
|---|---|
| function(event,xhr,options) | 必填。 指定请求成功时要运行的函数 额外参数:
|