Makes sure statusText always defaults to "error".
[jquery.git] / src / ajax.js
index 2b6b80f..15ad6a8 100644 (file)
@@ -365,9 +365,10 @@ jQuery.extend({
                                ( s.context = ( "context" in options ? options : jQuery.ajaxSettings ).context ) || s,
                        // Context for global events
                        // It's the callbackContext if one was provided in the options
-                       // and if it's a DOM node
-                       globalEventContext = callbackContext !== s && callbackContext.nodeType ?
-                               jQuery( callbackContext ) : jQuery.event,
+                       // and if it's a DOM node or a jQuery collection
+                       globalEventContext = callbackContext !== s &&
+                               ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
+                                               jQuery( callbackContext ) : jQuery.event,
                        // Deferreds
                        deferred = jQuery.Deferred(),
                        completeDeferred = jQuery._Deferred(),
@@ -508,7 +509,7 @@ jQuery.extend({
                                // We extract error from statusText
                                // then normalize statusText and status for non-aborts
                                error = statusText;
-                               if( status ) {
+                               if( !statusText || status ) {
                                        statusText = "error";
                                        if ( status < 0 ) {
                                                status = 0;