Skip to content

Commit

Permalink
fix(ajax): fixes error in Chrome accessing responseText when response…
Browse files Browse the repository at this point in the history
…Type isn't text.
  • Loading branch information
trxcllnt authored and benlesh committed Jan 27, 2016
1 parent 39ebae9 commit f3e2f73
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 @@ -295,12 +295,14 @@ export class AjaxSubscriber<T> extends Subscriber<Event> {
if (this.readyState === 4) {
// normalize IE9 bug (http://bugs.jquery.com/ticket/1450)
let status: number = this.status === 1223 ? 204 : this.status;
let response: any = (this.responseType === 'text' ? (
this.response || this.responseText) : this.response);

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

if (200 <= status && status < 300) {
Expand Down Expand Up @@ -391,4 +393,4 @@ export class AjaxTimeoutError extends AjaxError {
constructor(xhr: XMLHttpRequest, request: AjaxRequest) {
super('ajax timeout', xhr, request);
}
}
}

0 comments on commit f3e2f73

Please sign in to comment.