Using jQuery Autocomplete, according to the docs, you should do the following for caching:
<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>
Wasn't there a caching option? Thanks
Anapprentice
source share