Мой контроллер:
Код: Выделить всё
public function test() {
$keyword=$this->input->post('search[1]');
$data=$this->hbc_model->search_autocomplete($keyword);
//echo json_encode($data);
$this->load->view('headfoot/test-header-main');
$this->load->view('test');
$this->load->view('headfoot/test-footer-main');
}
Код: Выделить всё
function search_autocomplete($search_term){
$this->db->select('v_city_name');
$this->db->like('v_city_name', $search_term);
$response = $this->db->get('vbc_city')->result_array();
// var_dump($response);
return $response;
}
Код: Выделить всё
$(document).ready(function() {
$( "#main-search" ).autocomplete({
source: 'hbc_Model/search_autocomplete'
});
});
Подробнее здесь: https://stackoverflow.com/questions/385 ... db-to-work