From 9368a8cd8ca81902b8359188668973e489fca6db Mon Sep 17 00:00:00 2001 From: Oleg Gaidarenko Date: Sun, 15 Feb 2015 05:41:38 +0300 Subject: [PATCH] Ajax: remove deprecated extensions from ajax promise (cherry-picked from 9d1b989f20b550af3590691723b0620f6914626e) Fixes gh-2084 Closes gh-2092 --- src/ajax.js | 10 ++++------ test/unit/ajax.js | 12 ++++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/ajax.js b/src/ajax.js index d2b40d338..24425bac6 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -488,9 +488,7 @@ jQuery.extend({ }; // Attach deferreds - deferred.promise( jqXHR ).complete = completeDeferred.add; - jqXHR.success = jqXHR.done; - jqXHR.error = jqXHR.fail; + deferred.promise( jqXHR ); // Remove hash character (#7531: and string promotion) // Add protocol if not provided (prefilters might expect it) @@ -620,9 +618,9 @@ jQuery.extend({ strAbort = "abort"; // Install callbacks on deferreds - for ( i in { success: 1, error: 1, complete: 1 } ) { - jqXHR[ i ]( s[ i ] ); - } + completeDeferred.add( s.complete ); + jqXHR.done( s.success ); + jqXHR.fail( s.error ); // Get transport transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 718ddaf82..f030b48fc 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -72,11 +72,11 @@ module( "ajax", { }, success: true, afterSend: function( request ) { - request.complete(function() { + request.always(function() { ok( true, "complete" ); - }).success(function() { + }).done(function() { ok( true, "success" ); - }).error(function() { + }).fail(function() { ok( false, "error" ); }); } @@ -90,11 +90,11 @@ module( "ajax", { }, success: true, complete: function( xhr ) { - xhr.complete(function() { + xhr.always(function() { ok( true, "complete" ); - }).success(function() { + }).done(function() { ok( true, "success" ); - }).error(function() { + }).fail(function() { ok( false, "error" ); }); } -- 2.39.5