[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Maposmatic-dev] [PATCH 3/6] Abort suggest Ajax query before starting a
From: |
Thomas Petazzoni |
Subject: |
[Maposmatic-dev] [PATCH 3/6] Abort suggest Ajax query before starting a new one |
Date: |
Sat, 7 Aug 2010 23:39:21 +0200 |
The .abort() method of Ajax requests allows to abort the in flight
Ajax request. We use this to abort the previous Ajax request before
starting a new one, which avoid the problem of having old Ajax request
replies coming *after* new Ajax request replies.
Signed-off-by: Thomas Petazzoni <address@hidden>
---
www/media/map_rendering_form.js | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/www/media/map_rendering_form.js b/www/media/map_rendering_form.js
index e574b62..efc0502 100644
--- a/www/media/map_rendering_form.js
+++ b/www/media/map_rendering_form.js
@@ -316,6 +316,7 @@ function suggest(input, results, osm_id, options) {
var $osm_id = $(osm_id);
var timeout = false;
var shown = false;
+ var ajaxSuggestQuery = null;
closeSuggest(true);
@@ -413,6 +414,11 @@ function suggest(input, results, osm_id, options) {
return;
}
$(input).css('cursor', 'wait');
+
+ if (ajaxSuggestQuery != null)
+ ajaxSuggestQuery.abort();
+
+ ajaxSuggestQuery =
$.getJSON("/apis/nominatim/",
{ q: $input.val(), exclude: excludes },
handleNominatimResults);
--
1.7.0.4
- [Maposmatic-dev] [PATCH 1/6] Tell Emacs about the indentation level for JS code, Thomas Petazzoni, 2010/08/08
- [Maposmatic-dev] Re: [PATCH 1/6] Tell Emacs about the indentation level for JS code, Maxime Petazzoni, 2010/08/08
- [Maposmatic-dev] [PATCH 5/6] Re-indent properly prepareLanguagePanel(), Thomas Petazzoni, 2010/08/08
- [Maposmatic-dev] [PATCH 2/6] Ignore left/right movements in the suggestion box, Thomas Petazzoni, 2010/08/08
- [Maposmatic-dev] [PATCH 4/6] Use the reversegeo service to find the country code, Thomas Petazzoni, 2010/08/08
- [Maposmatic-dev] [PATCH 3/6] Abort suggest Ajax query before starting a new one,
Thomas Petazzoni <=
- [Maposmatic-dev] [PATCH 6/6] Improve the language selector, Thomas Petazzoni, 2010/08/08