Skip to content

Commit

Permalink
Autocomplete: Abort existing ajax requests when running new searches.
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgonzalez committed Aug 25, 2010
1 parent f115b48 commit da2be6a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ui/jquery.ui.autocomplete.js
Expand Up @@ -221,10 +221,14 @@ $.widget( "ui.autocomplete", {
} else if ( typeof this.options.source === "string" ) {
url = this.options.source;
this.source = function( request, response ) {
if (self.xhr) {
self.xhr.abort();
}
self.xhr = $.getJSON( url, request, function( data, status, xhr ) {
if ( xhr === self.xhr ) {
response.apply( this, arguments );
response( data );
}
self.xhr = null;
});
};
} else {
Expand Down

0 comments on commit da2be6a

Please sign in to comment.