mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Autocomplete: Abort existing ajax requests when running new searches.
This commit is contained in:
parent
f115b48d2b
commit
da2be6a2af
6
ui/jquery.ui.autocomplete.js
vendored
6
ui/jquery.ui.autocomplete.js
vendored
@ -221,10 +221,14 @@ $.widget( "ui.autocomplete", {
|
|||||||
} else if ( typeof this.options.source === "string" ) {
|
} else if ( typeof this.options.source === "string" ) {
|
||||||
url = this.options.source;
|
url = this.options.source;
|
||||||
this.source = function( request, response ) {
|
this.source = function( request, response ) {
|
||||||
|
if (self.xhr) {
|
||||||
|
self.xhr.abort();
|
||||||
|
}
|
||||||
self.xhr = $.getJSON( url, request, function( data, status, xhr ) {
|
self.xhr = $.getJSON( url, request, function( data, status, xhr ) {
|
||||||
if ( xhr === self.xhr ) {
|
if ( xhr === self.xhr ) {
|
||||||
response.apply( this, arguments );
|
response( data );
|
||||||
}
|
}
|
||||||
|
self.xhr = null;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user