Make XHR work for file:// urls

The response status will be 0 instead of a HTTP status code for file urls,
so we need to consider a status of 0 as success too.
This commit is contained in:
Andreas Hocevar
2016-07-28 11:45:20 +02:00
parent 3d57ea45cb
commit 7da5a5ae92
4 changed files with 10 additions and 5 deletions

View File

@@ -67,7 +67,8 @@ ol.inherits(ol.source.TileJSON, ol.source.TileImage);
*/
ol.source.TileJSON.prototype.onXHRLoad_ = function(event) {
var client = /** @type {XMLHttpRequest} */ (event.target);
if (client.status >= 200 && client.status < 300) {
// status will be 0 for file:// urls
if (!client.status || client.status >= 200 && client.status < 300) {
var response;
try {
response = /** @type {TileJSON} */(JSON.parse(client.responseText));