Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Commit ddecf45

Browse files
committed
Merge pull request #2 from brendankenny/master
Add support for arraybuffer and blob responseTypes
2 parents ae63267 + c452e9d commit ddecf45

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

core-ajax.html

+22
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@
7777
* `xml`: uses `XHR.responseXML`.
7878
*
7979
* `json`: uses `XHR.responseText` parsed as JSON.
80+
*
81+
* `arraybuffer`: uses `XHR.response`.
82+
*
83+
* `blob`: uses `XHR.response`.
84+
*
85+
* `document`: uses `XHR.response`.
8086
*
8187
* @attribute handleAs
8288
* @type string
@@ -226,6 +232,18 @@
226232
}
227233
},
228234

235+
documentHandler: function(xhr) {
236+
return xhr.response;
237+
},
238+
239+
blobHandler: function(xhr) {
240+
return xhr.response;
241+
},
242+
243+
arraybufferHandler: function(xhr) {
244+
return xhr.response;
245+
},
246+
229247
urlChanged: function() {
230248
if (!this.handleAs) {
231249
var ext = String(this.url).split('.').pop();
@@ -277,6 +295,10 @@
277295
if (this.contentType) {
278296
args.headers['content-type'] = this.contentType;
279297
}
298+
if (this.handleAs === 'arraybuffer' || this.handleAs === 'blob' ||
299+
this.handleAs === 'document') {
300+
args.responseType = this.handleAs;
301+
}
280302

281303
args.withCredentials = this.withCredentials;
282304
args.callback = this.receive.bind(this);

0 commit comments

Comments
 (0)