Skip to content

Commit baae6a8

Browse files
authored
Fixed success codes for ajax class (#100)
1 parent 3ee0758 commit baae6a8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/ajax.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ import { Events } from '@playcanvas/observer';
22

33
import { globals as api } from './globals';
44

5+
const SUCCESS_CODES = [
6+
200, // OK
7+
201, // Created
8+
202, // Accepted
9+
204 // No Content
10+
];
11+
512
type AjaxArgs = {
613
// The URL to make the request to.
714
url: string;
@@ -144,7 +151,7 @@ class Ajax<T> extends Events {
144151
this._progress = 1;
145152
this.emit('progress', 1);
146153

147-
if (this._xhr.status === 200 || this._xhr.status === 201) {
154+
if (SUCCESS_CODES.includes(this._xhr.status)) {
148155
if (this._notJson) {
149156
this.emit('load', this._xhr.status, this._xhr.responseText);
150157
} else {

0 commit comments

Comments
 (0)