在documentation of jQuery AJAX Events中,所有示例都使用jQuery DOM元素来声明这样的绑定:
$('.log').ajaxSend( hander );
我想捕获jQuery AJAX事件,而无需使用DOM元素将其附加,如下所示:
$.ajaxSend( function( event, jqXHR, ajaxOptions ){
console.log( "ajaxSend" );
console.log( "ajaxSend.event", event );
console.log( "ajaxSend.jqXHR", jqXHR );
console.log( "ajaxSend.ajaxOptions", ajaxOptions );
});
但是看起来不起作用:
Uncaught TypeError: Object function (a,b){return new e.fn.init(a,b,h)} has no method 'ajaxSend'
有什么建议吗?
解决方法:
您可以使用以下文档:
$(document).ajaxSend( hander );