Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#471 closed bug (fixed)

Please pass the XHR to global ajax callbacks (also add ajaxSend)

Reported by: malsup Owned by:
Priority: major Milestone:
Component: ajax Version:
Keywords: Cc:
Blocked by: Blocking:

Description

The global ajax callback methods ajaxSuccess, ajaxComplete, and ajaxError need to be passed the XMLHttpRequest object so they make use of it for intelligent error messages, etc.

jQuery.event.trigger( "ajaxSuccess", [xml] ); jQuery.event.trigger( "ajaxComplete", [xml] ); jQuery.event.trigger( "ajaxError", [xml] );

In addition, there should probably be a global ajaxSend method which is invoked after the new beforeSend callback. This will allow for XHR modifications such as request headers to be handled globally.

Allow custom headers/mimetypes if( s.beforeSend )

s.beforeSend(xml);

if (s.global)

jQuery.event.trigger("ajaxSend", [xml]);

Change History (3)

comment:1 Changed 12 years ago by anonymous

Oops. Darn formatting..

jQuery.event.trigger( "ajaxSuccess", [xml] ); 
jQuery.event.trigger( "ajaxComplete", [xml] ); 
jQuery.event.trigger( "ajaxError", [xml] );
// Allow custom headers/mimetypes 
if( s.beforeSend )
    s.beforeSend(xml); 
if (s.global) 
    jQuery.event.trigger("ajaxSend", [xml]);

comment:2 Changed 12 years ago by Abdur-Rahman

I would like the settings to be passed to the event of ajaxSend so I can modify headers based on the passed setting...

jQuery.event.trigger("ajaxSend", [xml, s]);

something like that..

comment:3 Changed 12 years ago by joern

Resolution: fixed
Status: newclosed

Fixed in SVN. ajaxSuccess, ajaxComplete, ajaxError and ajaxSend get the XMLHttpRequest and the settings passed as arguments.

Note: See TracTickets for help on using tickets.