mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Autocomplete cache demo: Let the widget handle request synchronization. Fixes #8616 - Remote autocomplete example can leave pending request tracking out of sync.
This commit is contained in:
parent
2c50b1b8b5
commit
5405a821b9
@ -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 );
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user