I am trying to achieve autocomplete search and I added all necessary jQuery but it still doesn't work.
Here is my View :
<script type="text/javascript">
$(document).ready(function(){
$('#dseancename').autocomplete({
source:"<?php echo site_url('AddSeance/search/?'); ?>"
});
});
And my Controller:
function search() {
$this->load->model('SalonModel');
if(isset($_GET['term'])){
$result = $this->SalonModel->search($_GET['term']);
if(count($result) >0){
foreach ($result as $pr)
$arr_result[] = $pr->name;
echo json_encode($arr_result);
}
}}
And my Model :
function search($name) {
$this->db->like('name',$name,'both');
return $this->db->get('seance')->result();//table name seance
}
I tried to make it an array and it works. But I can't make it with database values. I searched on the internet and find someone who already did it but it doesn't work to.