File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change 15
15
*/
16
16
( function ( $ , undefined ) {
17
17
18
+ // used to prevent race conditions with remote data sources
19
+ var requestIndex = 0 ;
20
+
18
21
$ . widget ( "ui.autocomplete" , {
19
22
defaultElement : "<input>" ,
20
23
options : {
@@ -257,17 +260,16 @@ $.widget( "ui.autocomplete", {
257
260
url : url ,
258
261
data : request ,
259
262
dataType : "json" ,
260
- success : function ( data , status , xhr ) {
261
- if ( xhr === self . xhr ) {
263
+ autocompleteRequest : ++ requestIndex ,
264
+ success : function ( data , status ) {
265
+ if ( this . autocompleteRequest === requestIndex ) {
262
266
response ( data ) ;
263
267
}
264
- self . xhr = null ;
265
268
} ,
266
- error : function ( xhr ) {
267
- if ( xhr === self . xhr ) {
269
+ error : function ( ) {
270
+ if ( this . autocompleteRequest === requestIndex ) {
268
271
response ( [ ] ) ;
269
272
}
270
- self . xhr = null ;
271
273
}
272
274
} ) ;
273
275
} ;
You can’t perform that action at this time.
0 commit comments