Skip to content
Permalink
Browse files

Fixes #9682. Removes data from the options for request with no conten…

…t so that it is not used again in case of a retry. Unit test added.
  • Loading branch information...
jaubourg committed Jul 1, 2011
1 parent 139135a commit e83fcdcb02d676d91d764a58f7e8d2eb1c95de69
Showing with 22 additions and 5 deletions.
  1. +2 −0 src/ajax.js
  2. +20 −5 test/unit/ajax.js
@@ -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
@@ -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() {

0 comments on commit e83fcdc

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.