diff --git a/src/ajax.js b/src/ajax.js index ab96c3625..3cbbc166d 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -713,8 +713,19 @@ jQuery.extend( { // Callback for when everything is done function done( status, nativeStatusText, responses, headers ) { - var isSuccess, success, error, response, modified, - statusText = nativeStatusText; + var isSuccess, success, error, response, modified, statusText; + + if ( typeof status === "object" ) { + + // The new, object-based API + nativeStatusText = status.statusText; + responses = status.responses; + headers = status.headers; + + status = status.status; + } + + statusText = nativeStatusText; // Ignore repeat invocations if ( completed ) { diff --git a/src/ajax/xhr.js b/src/ajax/xhr.js index c7b057a6e..8f3179a4e 100644 --- a/src/ajax/xhr.js +++ b/src/ajax/xhr.js @@ -63,23 +63,23 @@ jQuery.ajaxTransport( function( options ) { if ( type === "abort" ) { xhr.abort(); } else if ( type === "error" ) { - complete( + complete( { // File: protocol always yields status 0; see trac-8605, trac-14207 - xhr.status, - xhr.statusText - ); + status: xhr.status, + statusText: xhr.statusText + } ); } else { - complete( - xhrSuccessStatus[ xhr.status ] || xhr.status, - xhr.statusText, + complete( { + status: xhrSuccessStatus[ xhr.status ] || xhr.status, + statusText: xhr.statusText, // For XHR2 non-text, let the caller handle it (gh-2498) - ( xhr.responseType || "text" ) === "text" ? + responses: ( xhr.responseType || "text" ) === "text" ? { text: xhr.responseText } : { binary: xhr.response }, - xhr.getAllResponseHeaders() - ); + headers: xhr.getAllResponseHeaders() + } ); } } };