Joã*_*lva 19
不,ajaxStart你内部没有访问jqXHR对象,也没有ajaxOptions:
// Watch for a new set of requests
if ( s.global && jQuery.active++ === 0 ) {
jQuery.event.trigger( "ajaxStart" );
}
Run Code Online (Sandbox Code Playgroud)
如您所见,没有传递参数ajaxStart.与此对比ajaxSend:
// Send global event
if ( fireGlobals ) {
globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
}
Run Code Online (Sandbox Code Playgroud)
将jqXHR对象作为参数与设置一起传递的位置:
$(document).ajaxSend(function(evt, request, settings) {
alert("Starting request at " + settings.url + ".");
});
Run Code Online (Sandbox Code Playgroud)
另请参阅此答案以更好地了解此设计.
小智 9
您无法从ajaxstart函数获取请求的url,您只能使用ajaxsend函数,因为关于特定请求的ajaxsend函数但是ajaxstart不是
$( document ).ajaxSend(function( event, jqxhr, settings ) {
if ( settings.url == "ajax/test.html" ) {
$( ".log" ).text( "Triggered ajaxSend handler." );
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9476 次 |
| 最近记录: |