Skip to content

Commit 9368a8c

Browse files
committed
Ajax: remove deprecated extensions from ajax promise
(cherry-picked from 9d1b989) Fixes gh-2084 Closes gh-2092
1 parent 04fc801 commit 9368a8c

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/ajax.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,7 @@ jQuery.extend({
488488
};
489489

490490
// Attach deferreds
491-
deferred.promise( jqXHR ).complete = completeDeferred.add;
492-
jqXHR.success = jqXHR.done;
493-
jqXHR.error = jqXHR.fail;
491+
deferred.promise( jqXHR );
494492

495493
// Remove hash character (#7531: and string promotion)
496494
// Add protocol if not provided (prefilters might expect it)
@@ -620,9 +618,9 @@ jQuery.extend({
620618
strAbort = "abort";
621619

622620
// Install callbacks on deferreds
623-
for ( i in { success: 1, error: 1, complete: 1 } ) {
624-
jqXHR[ i ]( s[ i ] );
625-
}
621+
completeDeferred.add( s.complete );
622+
jqXHR.done( s.success );
623+
jqXHR.fail( s.error );
626624

627625
// Get transport
628626
transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );

test/unit/ajax.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ module( "ajax", {
7272
},
7373
success: true,
7474
afterSend: function( request ) {
75-
request.complete(function() {
75+
request.always(function() {
7676
ok( true, "complete" );
77-
}).success(function() {
77+
}).done(function() {
7878
ok( true, "success" );
79-
}).error(function() {
79+
}).fail(function() {
8080
ok( false, "error" );
8181
});
8282
}
@@ -90,11 +90,11 @@ module( "ajax", {
9090
},
9191
success: true,
9292
complete: function( xhr ) {
93-
xhr.complete(function() {
93+
xhr.always(function() {
9494
ok( true, "complete" );
95-
}).success(function() {
95+
}).done(function() {
9696
ok( true, "success" );
97-
}).error(function() {
97+
}).fail(function() {
9898
ok( false, "error" );
9999
});
100100
}

0 commit comments

Comments
 (0)