]> source.dussan.org Git - jquery.git/commitdiff
Fixes #9682. Removes data from the options for request with no content so that it...
authorjaubourg <j@ubourg.net>
Fri, 1 Jul 2011 00:11:26 +0000 (02:11 +0200)
committerjaubourg <j@ubourg.net>
Fri, 1 Jul 2011 00:11:26 +0000 (02:11 +0200)
src/ajax.js
test/unit/ajax.js

index e4e48dc7bffded8fa9fbd4bd5d1822500f7d3d87..650f33184aa97cd15fc91af09279b2d47dac2bf9 100644 (file)
@@ -644,6 +644,8 @@ jQuery.extend({
                        // If data is available, append data to url
                        if ( s.data ) {
                                s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
+                               // #9682: remove data so that it's not used in an eventual retry
+                               delete s.data;
                        }
 
                        // Get ifModifiedKey before adding the anti-cache parameter
index 9f084136e007f996d3dfa3a931ac60aef0bf049f..334339227ab6432e5082d10a8eeec54d8dc94cdd 100644 (file)
@@ -321,25 +321,40 @@ test("jQuery.ajax() - responseText on error", function() {
 
 test(".ajax() - retry with jQuery.ajax( this )", function() {
 
-       expect( 1 );
+       expect( 2 );
 
        stop();
 
-       var firstTime = 1;
+       var firstTime = true,
+               previousUrl;
 
        jQuery.ajax({
                url: url("data/errorWithText.php"),
                error: function() {
                        if ( firstTime ) {
-                               firstTime = 0;
+                               firstTime = false;
                                jQuery.ajax( this );
                        } else {
                                ok( true , "Test retrying with jQuery.ajax(this) works" );
-                               start();
+                               jQuery.ajax({
+                                       url: url("data/errorWithText.php"),
+                                       data: { x: 1 },
+                                       beforeSend: function() {
+                                               if ( !previousUrl ) {
+                                                       previousUrl = this.url;
+                                               } else {
+                                                       strictEqual( this.url , previousUrl, "url parameters are not re-appended" );
+                                                       start();
+                                                       return false;
+                                               }
+                                       },
+                                       error: function() {
+                                               jQuery.ajax( this );
+                                       }
+                               });
                        }
                }
        });
-
 });
 
 test(".ajax() - headers" , function() {