]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index/query.js
Abort any existing requests when starting new ones
[rails.git] / app / assets / javascripts / index / query.js
index 1a91c202ce9f0ccfc722d8ac05510fc901e95684..fb8649025328af184e9b5aa60e919941a4bd0d36 100644 (file)
@@ -176,8 +176,12 @@ OSM.Query = function(map) {
       $(this).show();
     });
 
-    $.ajax({
-      url: "http://overpass-api.de/api/interpreter",
+    if ($section.data("ajax")) {
+      $section.data("ajax").abort();
+    }
+
+    $section.data("ajax", $.ajax({
+      url: OSM.OVERPASS_URL,
       method: "POST",
       data: {
         data: "[timeout:5][out:json];" + query,
@@ -213,7 +217,7 @@ OSM.Query = function(map) {
             .appendTo($ul);
         }
       }
-    });
+    }));
   }
 
   function queryOverpass(lat, lng) {