Skip to content

Commit da2be6a

Browse files
committed
Autocomplete: Abort existing ajax requests when running new searches.
1 parent f115b48 commit da2be6a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ui/jquery.ui.autocomplete.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,14 @@ $.widget( "ui.autocomplete", {
221221
} else if ( typeof this.options.source === "string" ) {
222222
url = this.options.source;
223223
this.source = function( request, response ) {
224+
if (self.xhr) {
225+
self.xhr.abort();
226+
}
224227
self.xhr = $.getJSON( url, request, function( data, status, xhr ) {
225228
if ( xhr === self.xhr ) {
226-
response.apply( this, arguments );
229+
response( data );
227230
}
231+
self.xhr = null;
228232
});
229233
};
230234
} else {

0 commit comments

Comments
 (0)