Skip to content
Permalink
Browse files
Autocomplete cache demo: Let the widget handle request synchronizatio…
…n. Fixes #8616 - Remote autocomplete example can leave pending request tracking out of sync.
  • Loading branch information
scottgonzalez committed Oct 2, 2012
1 parent 2c50b1b commit 5405a82
Showing 1 changed file with 3 additions and 6 deletions.
@@ -18,8 +18,7 @@
</style>
<script>
$(function() {
var cache = {},
lastXhr;
var cache = {};
$( "#birds" ).autocomplete({
minLength: 2,
source: function( request, response ) {
@@ -29,11 +28,9 @@
return;
}

lastXhr = $.getJSON( "search.php", request, function( data, status, xhr ) {
$.getJSON( "search.php", request, function( data, status, xhr ) {
cache[ term ] = data;
if ( xhr === lastXhr ) {
response( data );
}
response( data );
});
}
});

0 comments on commit 5405a82

Please sign in to comment.