Skip to content

Commit bba13d8

Browse files
kwonojbenlesh
authored andcommitted
fix(AjaxObservable): support json responseType on IE
- IE does not support json responseType, internally parse it into JSON object closes #1381
1 parent 8162654 commit bba13d8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/observable/dom/AjaxObservable.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,13 @@ export class AjaxResponse {
375375

376376
constructor(public originalEvent: Event, public xhr: XMLHttpRequest, public request: AjaxRequest) {
377377
this.status = xhr.status;
378-
this.responseType = xhr.responseType;
378+
this.responseType = xhr.responseType || request.responseType;
379+
379380
switch (this.responseType) {
380381
case 'json':
381382
if ('response' in xhr) {
382-
this.response = xhr.response;
383+
//IE does not support json as responseType, parse it internally
384+
this.response = xhr.responseType ? xhr.response : JSON.parse(xhr.response || xhr.responseText || '');
383385
} else {
384386
this.response = JSON.parse(xhr.responseText || '');
385387
}

0 commit comments

Comments
 (0)