diff --git a/src/ajax.js b/src/ajax.js index a814d80b..744476f1 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -464,6 +464,11 @@ jQuery.extend({ } else { // if not success, mark it as an error error = error || statusText; + + // Set responseText if needed + if ( response ) { + jXHR.responseText = response; + } } // Set data for the fake xhr object diff --git a/src/ajax/xhr.js b/src/ajax/xhr.js index 032668f6..a2ec4a4c 100644 --- a/src/ajax/xhr.js +++ b/src/ajax/xhr.js @@ -137,15 +137,13 @@ jQuery.ajax.transport( function( s , determineDataType ) { status ); - // Guess response if needed & update datatype accordingly - if ( status >= 200 && status < 300 ) { - response = - determineDataType( - s, - xhr.getResponseHeader("content-type"), - xhr.responseText, - xhr.responseXML ); - } + // Guess response & update dataType accordingly + response = + determineDataType( + s, + xhr.getResponseHeader("content-type"), + xhr.responseText, + xhr.responseXML ); } // Call complete diff --git a/test/data/errorWithText.php b/test/data/errorWithText.php new file mode 100644 index 00000000..abd87321 --- /dev/null +++ b/test/data/errorWithText.php @@ -0,0 +1,5 @@ +