diff options
author | Christopher Baines <cb15g11@soton.ac.uk> | 2014-09-06 11:35:48 +0100 |
---|---|---|
committer | Christopher Baines <cb15g11@soton.ac.uk> | 2014-09-06 11:35:48 +0100 |
commit | 312dadcac1b6580f9c57f9b1165811eb994120a5 (patch) | |
tree | cdfbf30e494604e8e7feea2634c6b96ab41301d4 | |
parent | afe8e55ce120743983f8b6c4fc411d609ad73f6a (diff) | |
download | leaflet-soton-312dadcac1b6580f9c57f9b1165811eb994120a5.tar leaflet-soton-312dadcac1b6580f9c57f9b1165811eb994120a5.tar.gz |
Modify to refetch data on failure
Also lengthen timeout for fetching data. This should help using leaflet-soton
on mobile devices.
-rw-r--r-- | src/leaflet-soton.js | 12 |
1 files 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; |