Skip to main content

Bug Tracker

Side navigation

#471 closed bug (fixed)

Opened December 07, 2006 12:15AM UTC

Closed December 11, 2006 08:53AM UTC

Last modified June 20, 2007 02:37AM UTC

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]);

Attachments (0)
Change History (3)

Changed December 07, 2006 12:30AM UTC by anonymous comment:1

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]);

Changed December 07, 2006 12:18PM UTC by Abdur-Rahman comment:2

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..

Changed December 11, 2006 08:53AM UTC by joern comment:3

resolution: → fixed
status: newclosed

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