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.
(cherry picked from commit a1ab9678e9
)
This commit is contained in:
parent
e1174228c7
commit
6b9b513e77
14
ui/jquery.ui.autocomplete.js
vendored
14
ui/jquery.ui.autocomplete.js
vendored
@ -14,6 +14,9 @@
|
|||||||
*/
|
*/
|
||||||
(function( $, undefined ) {
|
(function( $, undefined ) {
|
||||||
|
|
||||||
|
// used to prevent race conditions with remote data sources
|
||||||
|
var requestIndex = 0;
|
||||||
|
|
||||||
$.widget( "ui.autocomplete", {
|
$.widget( "ui.autocomplete", {
|
||||||
options: {
|
options: {
|
||||||
appendTo: "body",
|
appendTo: "body",
|
||||||
@ -256,17 +259,16 @@ $.widget( "ui.autocomplete", {
|
|||||||
url: url,
|
url: url,
|
||||||
data: request,
|
data: request,
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function( data, status, xhr ) {
|
autocompleteRequest: ++requestIndex,
|
||||||
if ( xhr === self.xhr ) {
|
success: function( data, status ) {
|
||||||
|
if ( this.autocompleteRequest === requestIndex ) {
|
||||||
response( data );
|
response( data );
|
||||||
}
|
}
|
||||||
self.xhr = null;
|
|
||||||
},
|
},
|
||||||
error: function( xhr ) {
|
error: function() {
|
||||||
if ( xhr === self.xhr ) {
|
if ( this.autocompleteRequest === requestIndex ) {
|
||||||
response( [] );
|
response( [] );
|
||||||
}
|
}
|
||||||
self.xhr = null;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user