Allow XHR status 0 as success too

Normally only status 200 would be accepted as success, but 0 is returned when a file is loaded from the local filesystem (file://). This happens for example when opening the index.html of a (Phaser) game in a browser directly, or, as it turns out, when using Cordova on iOS.

This fixes #3464
This commit is contained in:
Ithamar R. Adema 2018-07-25 09:54:50 +02:00 committed by GitHub
parent 4c25d12b44
commit 44f9b10e8c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -315,7 +315,7 @@ var File = new Class({
*/ */
onLoad: function (xhr, event) onLoad: function (xhr, event)
{ {
var success = !(event.target && event.target.status !== 200); var success = !(event.target && (event.target.status !== 200 && event.target.status !== 0));
// Handle HTTP status codes of 4xx and 5xx as errors, even if xhr.onerror was not called. // Handle HTTP status codes of 4xx and 5xx as errors, even if xhr.onerror was not called.
if (xhr.readyState === 4 && xhr.status >= 400 && xhr.status <= 599) if (xhr.readyState === 4 && xhr.status >= 400 && xhr.status <= 599)