// Stored error
error,
- // Keep track of statusCode callbacks
- oldStatusCode = statusCode;
-
- statusCode = undefined;
+ // To keep track of statusCode based callbacks
+ oldStatusCode;
// If successful, handle type chaining
if ( status >= 200 && status < 300 || status === 304 ) {
}
// Status-dependent callbacks
+ oldStatusCode = statusCode;
+ statusCode = undefined;
jXHR.statusCode( oldStatusCode );
if ( s.global ) {
test( "jQuery.ajax - statusCode" , function() {
- var count = 10;
+ var count = 12;
- expect( 16 );
+ expect( 20 );
stop();
function countComplete() {
}
}).statusCode( createStatusCodes( "all (immediately with method)" , isSuccess ) );
- });
+ var testString = "";
+
+ jQuery.ajax( url( uri ), {
+ success: function( a , b , jXHR ) {
+ ok( isSuccess , "success" );
+ var statusCode = {};
+ statusCode[ jXHR.status ] = function() {
+ testString += "B";
+ };
+ jXHR.statusCode( statusCode );
+ testString += "A";
+ },
+ error: function( jXHR ) {
+ ok( ! isSuccess , "error" );
+ var statusCode = {};
+ statusCode[ jXHR.status ] = function() {
+ testString += "B";
+ };
+ jXHR.statusCode( statusCode );
+ testString += "A";
+ },
+ complete: function() {
+ strictEqual( testString , "AB" , "Test statusCode callbacks are ordered like " +
+ ( isSuccess ? "success" : "error" ) + " callbacks" );
+ countComplete();
+ }
+ } );
+ });
});
test("jQuery.ajax - active counter", function() {