Skip to content
Permalink
Browse files

Autocomplete: Fixed handling of race conditions when using jQuery 1.3…

….2. Fixes #6904 - Autocomplete: Race condition handling means.
  • Loading branch information
scottgonzalez committed Jan 27, 2011
1 parent 7a6dd71 commit a1ab9678e9bba6b20989104040bc31b782094335
Showing with 8 additions and 6 deletions.
  1. +8 −6 ui/jquery.ui.autocomplete.js
@@ -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;
}
});
};

1 comment on commit a1ab967

@scottgonzalez

This comment has been minimized.

Copy link
Member Author

scottgonzalez commented on a1ab967 Jun 19, 2011

Please provide a reduced test case showing the problem.

Please sign in to comment.
You can’t perform that action at this time.