From b74bd4213c12d662e1146a5b3035d95ba11aaf6f Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 3 Mar 2015 20:28:36 +0000 Subject: Cope with more failure states in the XMLHTTPRequest Previously, the callback would not be called if the status was not 200. --- src/leaflet-soton.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/leaflet-soton.js b/src/leaflet-soton.js index 0948789..ba5a138 100644 --- a/src/leaflet-soton.js +++ b/src/leaflet-soton.js @@ -1746,8 +1746,12 @@ SELECT * WHERE {\ xhttp.send(options.data); xhttp.onreadystatechange = function() { - if (xhttp.status == 200 && xhttp.readyState == 4) { - callback(JSON.parse(xhttp.responseText), xhttp.responseText); + if (xhttp.readyState === 4) { // loaded + if (xhttp.status === 200) { + callback(JSON.parse(xhttp.responseText), xhttp.responseText); + } else { + callback(null); + } } }; } -- cgit v1.2.3