Using jQuery Autocomplete, according to the docs you have to do the following to cache:
<script>
$(function() {
var cache = {},
lastXhr;
$( "#birds" ).autocomplete({
minLength: 2,
source: function( request, response ) {
var term = request.term;
if ( term in cache ) {
response( cache[ term ] );
return;
}
lastXhr = $.getJSON( "search.php", request, function( data, status, xhr ) {
cache[ term ] = data;
if ( xhr === lastXhr ) {
response( data );
}
});
}
});
});
</script>
Didn't there used to be an option to cache? Thanks
Caching for jQueryUI autocomplete was never an option.
There was a cacheLength
option for jQuery autocomplete (Jörn Zaefferer's now deprecated autocomplete plugin).
In the migration guide from autocomplete --> jQueryUI autocomplete, Jörn mentions this:
cacheLength: There is no built-in caching support anymore, but it's really easy to implement your own, as shown by the Remote with caching demo .
If you are using the caching implementation frequently, you could wrap the functionality in another plugin that encapsulates it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.