3

In the documentation of jQuery AJAX Events all the examples use a jQuery DOM Element for declare a binding like this:

$('.log').ajaxSend( hander );

I want to catch jQuery AJAX Events without the need of having a DOM Element to attach them, like this:

$.ajaxSend( function( event, jqXHR, ajaxOptions ){
  console.log( "ajaxSend" );
  console.log( "ajaxSend.event", event );
  console.log( "ajaxSend.jqXHR", jqXHR );
  console.log( "ajaxSend.ajaxOptions", ajaxOptions );
});

But It looks like it doesn't work:

Uncaught TypeError: Object function (a,b){return new e.fn.init(a,b,h)} has no method 'ajaxSend' 

Any suggestion?

4

2 に答える 2

4

You could use the document:

$(document).ajaxSend( hander );
于 2012-07-26T15:11:09.923 に答える
0

Sounds like you want to customize your ajax call in which using the $.fn.ajax call works great:

$.ajax('{your_url}', options);
于 2012-07-26T15:40:30.337 に答える