]> source.dussan.org Git - jquery.git/commitdiff
Fixes the parameters given to load callback when the request errors.
authorjaubourg <j@ubourg.net>
Wed, 2 May 2012 00:29:12 +0000 (02:29 +0200)
committerjaubourg <j@ubourg.net>
Wed, 2 May 2012 00:29:12 +0000 (02:29 +0200)
src/ajax.js

index 84a2c0432b89ce03d3001bd13e9bb79e9c097962..77e4d33e3a86111b78f5bbafe9c2c2097e6189ac 100644 (file)
@@ -167,7 +167,8 @@ jQuery.fn.extend({
 
                var selector, type,
                        self = this,
-                       off = url.indexOf(" ");
+                       off = url.indexOf(" "),
+                       response;
 
                if ( off >= 0 ) {
                        selector = url.slice( off, url.length );
@@ -193,9 +194,17 @@ jQuery.fn.extend({
                        // if "type" variable is undefined, then "GET" method will be used
                        type: type,
                        dataType: "html",
-                       data: params
+                       data: params,
+                       complete: function( jqXHR, status ) {
+                               if ( callback ) {
+                                       self.each( callback, [ status === "success" ? response : jqXHR.responseText, status, jqXHR ] );
+                               }
+                       }
                }).done(function( responseText ) {
 
+                       // Save response text for use in complete callback
+                       response = responseText;
+
                        // See if a selector was specified
                        self.html( selector ?
 
@@ -212,10 +221,6 @@ jQuery.fn.extend({
                                // If not, just inject the full result
                                responseText );
 
-               }).always(function() {
-                       if ( callback ) {
-                               self.each( callback, arguments );
-                       }
                });
 
                return this;