From b6d0d9eb14de2b303a65ca1ef67bd24f64ad8d20 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Tue, 8 Oct 2013 14:02:52 +0200 Subject: [PATCH] Cancel previous search autocompletion requests when a new one is sent --- public_html/static/js/openng.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/public_html/static/js/openng.js b/public_html/static/js/openng.js index c394c3a..43f3b16 100644 --- a/public_html/static/js/openng.js +++ b/public_html/static/js/openng.js @@ -200,7 +200,12 @@ SearchCompletionSource.prototype.getItem = function(index) { } SearchCompletionSource.prototype.updateItems = function(query, callback) { - $.ajax({ + if(typeof this.request !== "undefined") + { + this.request.abort(); + } + + this.request = $.ajax({ url: "/autocomplete/search/?q=" + escape(query), dataType: "json", success: function(result) { this.results = result; callback(); }.bind(this)