Skip to content

Commit

Permalink
fix(AjaxObservable): support json responseType on IE
Browse files Browse the repository at this point in the history
- IE does not support json responseType, internally parse it into JSON object

closes #1381
  • Loading branch information
kwonoj authored and benlesh committed Apr 12, 2016
1 parent 8162654 commit bba13d8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/observable/dom/AjaxObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,13 @@ export class AjaxResponse {

constructor(public originalEvent: Event, public xhr: XMLHttpRequest, public request: AjaxRequest) {
this.status = xhr.status;
this.responseType = xhr.responseType;
this.responseType = xhr.responseType || request.responseType;

switch (this.responseType) {
case 'json':
if ('response' in xhr) {
this.response = xhr.response;
//IE does not support json as responseType, parse it internally
this.response = xhr.responseType ? xhr.response : JSON.parse(xhr.response || xhr.responseText || '');
} else {
this.response = JSON.parse(xhr.responseText || '');
}
Expand Down

0 comments on commit bba13d8

Please sign in to comment.