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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With