Skip to content

Commit f3e2f73

Browse files
trxcllntbenlesh
authored andcommitted
fix(ajax): fixes error in Chrome accessing responseText when responseType isn't text.
1 parent 39ebae9 commit f3e2f73

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
@@ -295,12 +295,14 @@ export class AjaxSubscriber<T> extends Subscriber<Event> {
295295
if (this.readyState === 4) {
296296
// normalize IE9 bug (http://bugs.jquery.com/ticket/1450)
297297
let status: number = this.status === 1223 ? 204 : this.status;
298+
let response: any = (this.responseType === 'text' ? (
299+
this.response || this.responseText) : this.response);
298300

299301
// fix status code when it is 0 (0 status is undocumented).
300302
// Occurs when accessing file resources or on Android 4.1 stock browser
301303
// while retrieving files from application cache.
302304
if (status === 0) {
303-
status = (this.response || this.responseText) ? 200 : 0;
305+
status = response ? 200 : 0;
304306
}
305307

306308
if (200 <= status && status < 300) {
@@ -391,4 +393,4 @@ export class AjaxTimeoutError extends AjaxError {
391393
constructor(xhr: XMLHttpRequest, request: AjaxRequest) {
392394
super('ajax timeout', xhr, request);
393395
}
394-
}
396+
}

0 commit comments

Comments
 (0)