From your Ajax controller return an array. That array, is then converted into autocomplete options.
Caching is enabled. If you have already typed a word and undo then retype, it won't make more ajax calls. It will attain previous data.
Cjax 5.9 adds alot of power to autocomplete. More stability, more scalability, more caching and overall more complete and more features.
Note: These new features should be considered beta, which means, they could change in the future.
Two more optional parameters. boolean $full_load and string $url2
Realizing that every time you type a key, triggers an ajax call to the server, you may want to instead load all data at once, and not request the server as much. True / False, this options lets you load all the data at once. Intead of making an ajax request for each letter you type, you can dump a full array of data once, this data is then cached. When used this way, only one ajax call to the server is made. When you type more, the data obtained is filtered to serve the other keys you type.
Additionally, you can -
Preload: Need to load large amount of data? No problem. You can preload it. This can ensure that the
autocomplete acts really fast even with very large amounts of data.
With the new caching capabilities, you can take advantage of these caching capabilities by preloading the data you want to use. When the autocomplete kicks in all the data will be already be in place. You can take advanage of this by making an ajax request to the same url you are using for the autocomplete, and using the cache flag in the call() method. This wil cache data, when the autocomplete triggers the request, it will be served from cache, without making any other ajax request.
//assuming the method is ajax.php?autocomplete/full
//this will cache this data in the client side.
//If you trigger any more requests to this url they will be served from cache, and the same response that was obtained the first time
//will be served all the time.
$ajax->call(array('autocomplete','full',null, array('cache' => true)));
$url2If you would like to trigger an ajax request when of the one items is selected in the autocomplete, here is where you do it. Specifiy a $url by default, the name of the item you select will be added to the url as a controller parameter. In your ajax contoller you should get this name in the first argument. You can also choose to send an id instead, if your original data array contains ids, you can specify a forth parameter with the word 'id' and the id will be sent.
$ajax->keyup('#text2', $ajax->autocomplete('ajax.php?autocomplete/full', true ,'ajax.php?controller/method','id'));
Note: Current limitation in autocomplete you can only have one instance on a page.