Skip to content

Commit 5405a82

Browse files
committed
Autocomplete cache demo: Let the widget handle request synchronization. Fixes #8616 - Remote autocomplete example can leave pending request tracking out of sync.
1 parent 2c50b1b commit 5405a82

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

demos/autocomplete/remote-with-cache.html

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
</style>
1919
<script>
2020
$(function() {
21-
var cache = {},
22-
lastXhr;
21+
var cache = {};
2322
$( "#birds" ).autocomplete({
2423
minLength: 2,
2524
source: function( request, response ) {
@@ -29,11 +28,9 @@
2928
return;
3029
}
3130

32-
lastXhr = $.getJSON( "search.php", request, function( data, status, xhr ) {
31+
$.getJSON( "search.php", request, function( data, status, xhr ) {
3332
cache[ term ] = data;
34-
if ( xhr === lastXhr ) {
35-
response( data );
36-
}
33+
response( data );
3734
});
3835
}
3936
});

0 commit comments

Comments
 (0)