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 <[email protected]> --- 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
