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 14
14
*/
15
15
( function ( $ , undefined ) {
16
16
17
+ // used to prevent race conditions with remote data sources
18
+ var requestIndex = 0 ;
19
+
17
20
$ . widget ( "ui.autocomplete" , {
18
21
options : {
19
22
appendTo : "body" ,
@@ -256,17 +259,16 @@ $.widget( "ui.autocomplete", {
256
259
url : url ,
257
260
data : request ,
258
261
dataType : "json" ,
259
- success : function ( data , status , xhr ) {
260
- if ( xhr === self . xhr ) {
262
+ autocompleteRequest : ++ requestIndex ,
263
+ success : function ( data , status ) {
264
+ if ( this . autocompleteRequest === requestIndex ) {
261
265
response ( data ) ;
262
266
}
263
- self . xhr = null ;
264
267
} ,
265
- error : function ( xhr ) {
266
- if ( xhr === self . xhr ) {
268
+ error : function ( ) {
269
+ if ( this . autocompleteRequest === requestIndex ) {
267
270
response ( [ ] ) ;
268
271
}
269
- self . xhr = null ;
270
272
}
271
273
} ) ;
272
274
} ;
You can’t perform that action at this time.
0 commit comments