Автозаполнение данными не так уж сложно. Сначала вам нужно установить тип возврата. Самый простой, как правило, в формате JSON так:
Конец контроллера PHP
// be sure to use echo, not return
echo json_encode($yourDataAsArrayOrObject);
После завершения этой части вернитесь к своему javascript
$("#item").autocomplete({
// source should be a url to the controller function that returns the data
source: 'www.yoursite.com/controller/function',
search: function(e, ui) {}, // here you can manipulate other elements or items while the data is being retrieved,
select: function(e, ui) { /* ui.item is item slected */ } // here you can manipluate things based on the item that was selected, for instance, save a list of sub data to another dom element
});
Наконец, предостережение
// You will need to use ._renderItem to items as they are received by database.
// For instance, if you want to display the dropdown items in a custom way.
$("#item")._renderItem = function(ul, item) {
// the item. depends on the information you got from server
return ul.append($("<li></li>").prepend($("<h3></h3>").text(item.label)).append($("<p></p>").text(item.value)));
};