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 bc4c267..fb86490 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) {