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

Commit

Permalink
Merge pull request #2 from brendankenny/master
Browse files Browse the repository at this point in the history
Add support for arraybuffer and blob responseTypes
  • Loading branch information
ebidel committed Apr 23, 2014
2 parents ae63267 + c452e9d commit ddecf45
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions core-ajax.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@
* `xml`: uses `XHR.responseXML`.
*
* `json`: uses `XHR.responseText` parsed as JSON.
*
* `arraybuffer`: uses `XHR.response`.
*
* `blob`: uses `XHR.response`.
*
* `document`: uses `XHR.response`.
*
* @attribute handleAs
* @type string
Expand Down Expand Up @@ -226,6 +232,18 @@
}
},

documentHandler: function(xhr) {
return xhr.response;
},

blobHandler: function(xhr) {
return xhr.response;
},

arraybufferHandler: function(xhr) {
return xhr.response;
},

urlChanged: function() {
if (!this.handleAs) {
var ext = String(this.url).split('.').pop();
Expand Down Expand Up @@ -277,6 +295,10 @@
if (this.contentType) {
args.headers['content-type'] = this.contentType;
}
if (this.handleAs === 'arraybuffer' || this.handleAs === 'blob' ||
this.handleAs === 'document') {
args.responseType = this.handleAs;
}

args.withCredentials = this.withCredentials;
args.callback = this.receive.bind(this);
Expand Down

0 comments on commit ddecf45

Please sign in to comment.