контроллер
Код: Выделить всё
public function search(){
$search = $this->input->post('search');
$query = $this->products->search($search);
$data = array();
foreach ($query as $key => $value) {
$this->json($value);
}
}
Код: Выделить всё
public function search($data){
$this->db->like('description',$data,'both');
$query = $this->db->get('storelte_products');
return $query->result_array();
}
Код: Выделить всё
$('#search').typeahead({
source: function (query,process) {
$.ajax({
url: URL_SEARCH_PRODUCT,
type: 'POST',
data: {query: query},
dataType: 'json',
async: true,
success: function (data) {
console.log(data);
process(data.description);
}
});
}
});

json
Код: Выделить всё
{"id":"4165","provider_id":"1005","hash_id":"a7f0d2b95c60161b3f3c82f764b1d1c9","code":"BCBF-BE6A","description":"ajg","purchase_price":"7.00","sale_price":"77.00","wholesale_price":"7.00","min_stock":"7","stock":"7","max_stock":"7","created_at":"2017-04-09 22:21:28","status":"1"}

Подробнее здесь: https://stackoverflow.com/questions/433 ... -by-letter