Fixes #9682. Removes data from the options for request with no content so that it is not used again in case of a retry. Unit test added.
This commit is contained in:
parent
139135a98a
commit
e83fcdcb02
|
@ -644,6 +644,8 @@ jQuery.extend({
|
||||||
// If data is available, append data to url
|
// If data is available, append data to url
|
||||||
if ( s.data ) {
|
if ( s.data ) {
|
||||||
s.url += ( rquery.test( s.url ) ? "&" : "?" ) + 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
|
// 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() {
|
test(".ajax() - retry with jQuery.ajax( this )", function() {
|
||||||
|
|
||||||
expect( 1 );
|
expect( 2 );
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
var firstTime = 1;
|
var firstTime = true,
|
||||||
|
previousUrl;
|
||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
url: url("data/errorWithText.php"),
|
url: url("data/errorWithText.php"),
|
||||||
error: function() {
|
error: function() {
|
||||||
if ( firstTime ) {
|
if ( firstTime ) {
|
||||||
firstTime = 0;
|
firstTime = false;
|
||||||
jQuery.ajax( this );
|
jQuery.ajax( this );
|
||||||
} else {
|
} else {
|
||||||
ok( true , "Test retrying with jQuery.ajax(this) works" );
|
ok( true , "Test retrying with jQuery.ajax(this) works" );
|
||||||
|
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();
|
start();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
jQuery.ajax( this );
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test(".ajax() - headers" , function() {
|
test(".ajax() - headers" , function() {
|
||||||
|
|
Loading…
Reference in a new issue