]> source.dussan.org Git - jquery.git/commitdiff
Ajax: remove deprecated extensions from ajax promise
authorOleg Gaidarenko <markelog@gmail.com>
Sun, 15 Feb 2015 02:41:38 +0000 (05:41 +0300)
committerOleg Gaidarenko <markelog@gmail.com>
Tue, 17 Feb 2015 06:59:22 +0000 (09:59 +0300)
(cherry-picked from 9d1b989f20b550af3590691723b0620f6914626e)
Fixes gh-2084
Closes gh-2092

src/ajax.js
test/unit/ajax.js

index d2b40d338ea941dafc1feb35490320fc463d04d6..24425bac6ba7ffe8380c8210cad3468cce868bda 100644 (file)
@@ -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 );
index 718ddaf828f63d03a5873f961075f03c496d8fee..f030b48fc7e5b9b302b6cc5268d426c0aba784e5 100644 (file)
@@ -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" );
                        });
                }