From 312dadcac1b6580f9c57f9b1165811eb994120a5 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 6 Sep 2014 11:35:48 +0100 Subject: Modify to refetch data on failure Also lengthen timeout for fetching data. This should help using leaflet-soton on mobile devices. --- src/leaflet-soton.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/leaflet-soton.js b/src/leaflet-soton.js index 3cbb300..009df98 100644 --- a/src/leaflet-soton.js +++ b/src/leaflet-soton.js @@ -19,9 +19,17 @@ if (!this._dataFetchInProgress) { this._dataFetchInProgress = true; getJSON({url: LS.dataPath, cache: false} , function(data) { - LS.data = data; LS._dataFetchInProgress = false; + if (data === null) { + setTimeout(function() { + LS.getData(callback); + }, 1000); + return; + } + + LS.data = data; + LS.fire("dataload", data); }); } @@ -1609,7 +1617,7 @@ SELECT * WHERE {\ xhttp.ontimeout = function () { callback(null); }; - xhttp.timeout = 2000; + xhttp.timeout = 3000; options.data = options.data || null; -- cgit v1.2.3