From 5dc41fb0d59ad2f953ea0fda9bb17c8aa5a24dd4 Mon Sep 17 00:00:00 2001 From: Boris Cosic Date: Sat, 13 Jul 2013 17:18:41 -0600 Subject: [PATCH] Abort ajax requests in progress. --- src/jquery.autocomplete.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/jquery.autocomplete.js b/src/jquery.autocomplete.js index cc4e4b1..fce25af 100644 --- a/src/jquery.autocomplete.js +++ b/src/jquery.autocomplete.js @@ -71,6 +71,7 @@ containerClass: 'autocomplete-suggestions', tabDisabled: false, dataType: 'text', + currentRequest: null, lookupFilter: function (suggestion, originalQuery, queryLowerCase) { return suggestion.value.toLowerCase().indexOf(queryLowerCase) !== -1; }, @@ -428,7 +429,10 @@ if ($.isFunction(options.serviceUrl)) { serviceUrl = options.serviceUrl.call(that.element, q); } - $.ajax({ + if(this.currentRequest != null) { + this.currentRequest.abort(); + } + this.currentRequest = $.ajax({ url: serviceUrl, data: options.ignoreParams ? null : options.params, type: options.type,