Skip to content

Commit 5dc41fb

Browse files
author
Boris Cosic
committed
Abort ajax requests in progress.
1 parent 6a9c2ca commit 5dc41fb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/jquery.autocomplete.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
containerClass: 'autocomplete-suggestions',
7272
tabDisabled: false,
7373
dataType: 'text',
74+
currentRequest: null,
7475
lookupFilter: function (suggestion, originalQuery, queryLowerCase) {
7576
return suggestion.value.toLowerCase().indexOf(queryLowerCase) !== -1;
7677
},
@@ -428,7 +429,10 @@
428429
if ($.isFunction(options.serviceUrl)) {
429430
serviceUrl = options.serviceUrl.call(that.element, q);
430431
}
431-
$.ajax({
432+
if(this.currentRequest != null) {
433+
this.currentRequest.abort();
434+
}
435+
this.currentRequest = $.ajax({
432436
url: serviceUrl,
433437
data: options.ignoreParams ? null : options.params,
434438
type: options.type,

0 commit comments

Comments
 (0)