Skip to content

Commit e83fcdc

Browse files
committed
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.
1 parent 139135a commit e83fcdc

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/ajax.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,8 @@ jQuery.extend({
644644
// If data is available, append data to url
645645
if ( s.data ) {
646646
s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
647+
// #9682: remove data so that it's not used in an eventual retry
648+
delete s.data;
647649
}
648650

649651
// Get ifModifiedKey before adding the anti-cache parameter

test/unit/ajax.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,25 +321,40 @@ test("jQuery.ajax() - responseText on error", function() {
321321

322322
test(".ajax() - retry with jQuery.ajax( this )", function() {
323323

324-
expect( 1 );
324+
expect( 2 );
325325

326326
stop();
327327

328-
var firstTime = 1;
328+
var firstTime = true,
329+
previousUrl;
329330

330331
jQuery.ajax({
331332
url: url("data/errorWithText.php"),
332333
error: function() {
333334
if ( firstTime ) {
334-
firstTime = 0;
335+
firstTime = false;
335336
jQuery.ajax( this );
336337
} else {
337338
ok( true , "Test retrying with jQuery.ajax(this) works" );
338-
start();
339+
jQuery.ajax({
340+
url: url("data/errorWithText.php"),
341+
data: { x: 1 },
342+
beforeSend: function() {
343+
if ( !previousUrl ) {
344+
previousUrl = this.url;
345+
} else {
346+
strictEqual( this.url , previousUrl, "url parameters are not re-appended" );
347+
start();
348+
return false;
349+
}
350+
},
351+
error: function() {
352+
jQuery.ajax( this );
353+
}
354+
});
339355
}
340356
}
341357
});
342-
343358
});
344359

345360
test(".ajax() - headers" , function() {

0 commit comments

Comments
 (0)