X-Git-Url: http://git.asbjorn.biz/?p=jquery.git;a=blobdiff_plain;f=src%2Fajax.js;h=8f8bc60ab07fc1105ff4a1377857fdb8dc238854;hp=89d60e1d008e75788d6e8de5bad8bffb229c36f7;hb=5ca8f0617f5c94495380ff783452a52eab706d39;hpb=33de9c559789d7f4565c9c57a7152f3ca2721b65 diff --git a/src/ajax.js b/src/ajax.js index 89d60e1..8f8bc60 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -400,8 +400,9 @@ jQuery.extend({ // Cancel the request abort: function( statusText ) { + statusText = statusText || "abort"; if ( transport ) { - transport.abort( statusText || "abort" ); + transport.abort( statusText ); } done( 0, statusText ); return this; @@ -438,7 +439,7 @@ jQuery.extend({ var isSuccess, success, - error = ( statusText = statusText || "error" ), + error, response = responses ? ajaxHandleResponses( s, jXHR, responses ) : undefined, lastModified, etag; @@ -476,6 +477,16 @@ jQuery.extend({ error = "" + e; } } + } else { + // We extract error from statusText + // then normalize statusText and status for non-aborts + error = statusText; + if( status ) { + statusText = "error"; + if ( status < 0 ) { + status = 0; + } + } } // Set data for the fake xhr object @@ -634,7 +645,7 @@ jQuery.extend({ // If no transport, we auto-abort if ( !transport ) { - done( 0, "notransport" ); + done( -1, "No Transport" ); } else { // Set state as sending state = jXHR.readyState = 1; @@ -653,9 +664,8 @@ jQuery.extend({ transport.send( requestHeaders, done ); } catch (e) { // Propagate exception as error if not done - if ( status === 1 ) { - done( 0, "error", "" + e ); - jXHR = false; + if ( status < 2 ) { + done( -1, "" + e ); // Simply rethrow otherwise } else { jQuery.error( e );