From: Tom Hughes Date: Tue, 30 Jul 2013 20:30:16 +0000 (+0100) Subject: Abort a running data browser load before starting a new one X-Git-Tag: live~4875 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/90621b4b4f2b48a1dddde89bbaf748c3776e2020 Abort a running data browser load before starting a new one --- diff --git a/app/assets/javascripts/index/browse.js b/app/assets/javascripts/index/browse.js index e04a864f4..07cff50f0 100644 --- a/app/assets/javascripts/index/browse.js +++ b/app/assets/javascripts/index/browse.js @@ -136,6 +136,8 @@ function initializeBrowse(map) { $("#browse_content").append(div); } + var dataLoader; + function getData() { var bounds = locationFilter.isEnabled() ? locationFilter.getBounds() : map.getBounds(); var size = bounds.getSize(); @@ -164,7 +166,9 @@ function initializeBrowse(map) { } @*/ - $.ajax({ + if (dataLoader) dataLoader.abort(); + + dataLoader = $.ajax({ url: url, success: function (xml) { clearStatus(); @@ -203,6 +207,8 @@ function initializeBrowse(map) { } else { displayFeatureWarning(features.length, maxFeatures, addFeatures); } + + dataLoader = null; } }); }