aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2015-10-31 11:24:04 -0400
committerDave Methvin <dave.methvin@gmail.com>2015-11-04 12:47:16 -0500
commit769446c69775f6c44e35cee1bcdeccafba51be7b (patch)
treeede10c3a724f9460a41e4e85def8212cb768f073 /src
parent76e9a95dbeaf28fbc5a64571ebb5959f91a9c14a (diff)
downloadjquery-769446c69775f6c44e35cee1bcdeccafba51be7b.tar.gz
jquery-769446c69775f6c44e35cee1bcdeccafba51be7b.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/ajax/xhr.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/ajax/xhr.js b/src/ajax/xhr.js
index fd4a733e5..db670ff15 100644
--- a/src/ajax/xhr.js
+++ b/src/ajax/xhr.js
@@ -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()
);
}