5 <title>jQuery UI Autocomplete - Remote with caching</title>
6 <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
7 <script src="../../jquery-1.9.1.js"></script>
8 <script src="../../ui/jquery.ui.core.js"></script>
9 <script src="../../ui/jquery.ui.widget.js"></script>
10 <script src="../../ui/jquery.ui.position.js"></script>
11 <script src="../../ui/jquery.ui.menu.js"></script>
12 <script src="../../ui/jquery.ui.autocomplete.js"></script>
13 <link rel="stylesheet" href="../demos.css">
15 .ui-autocomplete-loading {
16 background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat;
22 $( "#birds" ).autocomplete({
24 source: function( request, response ) {
25 var term = request.term;
26 if ( term in cache ) {
27 response( cache[ term ] );
31 $.getJSON( "search.php", request, function( data, status, xhr ) {
42 <div class="ui-widget">
43 <label for="birds">Birds: </label>
47 <div class="demo-description">
48 <p>The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are bird names, displayed when at least two characters are entered into the field.</p>
49 <p>Similar to the remote datasource demo, though this adds some local caching to improve performance. The cache here saves just one query, and could be extended to cache multiple values, one for each term.</p>