mirror of
https://github.com/jquery/jquery.git
synced 2026-02-01 06:55:02 -05:00
Ajax: Don't throw exceptions on binary data response
Fixes gh-2498 Closes gh-2682 The added unit test shows how this could be used to support an ArrayBuffer return, but $.ajax does not support it natively. The goal with this change was to avoid the exception.
This commit is contained in:
@@ -97,12 +97,13 @@ jQuery.ajaxTransport( function( options ) {
|
||||
xhrSuccessStatus[ xhr.status ] || xhr.status,
|
||||
xhr.statusText,
|
||||
|
||||
// Support: IE9
|
||||
// Accessing binary-data responseText throws an exception
|
||||
// (#11426)
|
||||
typeof xhr.responseText === "string" ? {
|
||||
text: xhr.responseText
|
||||
} : undefined,
|
||||
// Support: IE9 only
|
||||
// IE9 has no XHR2 but throws on binary (trac-11426)
|
||||
// For XHR2 non-text, let the caller handle it (gh-2498)
|
||||
( xhr.responseType || "text" ) !== "text" ||
|
||||
typeof xhr.responseText !== "string" ?
|
||||
{ binary: xhr.response } :
|
||||
{ text: xhr.responseText },
|
||||
xhr.getAllResponseHeaders()
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user