mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Autocomplete: Fixed handling of race conditions when using jQuery 1.3.2. Fixes #6904 - Autocomplete: Race condition handling means.
This commit is contained in:
parent
7a6dd71f8c
commit
a1ab9678e9
14
ui/jquery.ui.autocomplete.js
vendored
14
ui/jquery.ui.autocomplete.js
vendored
@ -15,6 +15,9 @@
|
||||
*/
|
||||
(function( $, undefined ) {
|
||||
|
||||
// used to prevent race conditions with remote data sources
|
||||
var requestIndex = 0;
|
||||
|
||||
$.widget( "ui.autocomplete", {
|
||||
defaultElement: "<input>",
|
||||
options: {
|
||||
@ -257,17 +260,16 @@ $.widget( "ui.autocomplete", {
|
||||
url: url,
|
||||
data: request,
|
||||
dataType: "json",
|
||||
success: function( data, status, xhr ) {
|
||||
if ( xhr === self.xhr ) {
|
||||
autocompleteRequest: ++requestIndex,
|
||||
success: function( data, status ) {
|
||||
if ( this.autocompleteRequest === requestIndex ) {
|
||||
response( data );
|
||||
}
|
||||
self.xhr = null;
|
||||
},
|
||||
error: function( xhr ) {
|
||||
if ( xhr === self.xhr ) {
|
||||
error: function() {
|
||||
if ( this.autocompleteRequest === requestIndex ) {
|
||||
response( [] );
|
||||
}
|
||||
self.xhr = null;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user