]> source.dussan.org Git - jquery.git/commitdiff
Ajax: replace "jqXHR.complete" callback with "always"
authorOleg Gaidarenko <markelog@gmail.com>
Wed, 11 Feb 2015 13:40:40 +0000 (16:40 +0300)
committerOleg Gaidarenko <markelog@gmail.com>
Sat, 14 Feb 2015 23:05:39 +0000 (02:05 +0300)
Since it was deprecated since 1.8.

Also add additional comments which explains tricky
behaviour of "always" callback

Closes gh-2033

src/ajax/load.js

index 5950614437f24b856987dd9a995781d25d41a85a..f8f0c396a8c4c9436c0eb82741c0d7cac9986704 100644 (file)
@@ -66,7 +66,10 @@ jQuery.fn.load = function( url, params, callback ) {
                                // Otherwise use the full result
                                responseText );
 
-               }).complete( callback && function( jqXHR, status ) {
+               // If the request succeeds, this function gets "data", "status", "jqXHR"
+               // but they are ignored because response was set above.
+               // If it fails, this function gets "jqXHR", "status", "error"
+               }).always( callback && function( jqXHR, status ) {
                        self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
                });
        }