Abort any existing requests when starting new ones
authorTom Hughes <tom@compton.nu>
Thu, 13 Mar 2014 22:59:36 +0000 (22:59 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 16 Mar 2014 16:18:13 +0000 (16:18 +0000)
app/assets/javascripts/index/query.js

index bc4c26771913e6f4fbb855fc3b7064400b0f0482..fb8649025328af184e9b5aa60e919941a4bd0d36 100644 (file)
@@ -176,7 +176,11 @@ OSM.Query = function(map) {
       $(this).show();
     });
 
-    $.ajax({
+    if ($section.data("ajax")) {
+      $section.data("ajax").abort();
+    }
+
+    $section.data("ajax", $.ajax({
       url: OSM.OVERPASS_URL,
       method: "POST",
       data: {
@@ -213,7 +217,7 @@ OSM.Query = function(map) {
             .appendTo($ul);
         }
       }
-    });
+    }));
   }
 
   function queryOverpass(lat, lng) {