Good afternoon guys,
I have a search field where I give "suggestions" rather than typing, based on what I have registered in my database. It was working perfectly, but it stopped working and I can not find the error.
Script:
<script>
$(function(){
$('#query').autocomplete({
source: "<?php echo site_url('artigos/sugestao'); ?>"
});
});
</script>
Controller:
public function sugestao()
{
if(esta_logado() == TRUE){
if(isset($_GET['term'])){
$result = $this->artigos->sugestao($_GET['term']);
if(count($result) > 0){
foreach ($result as $r)
$arr_result[] = $r->titulo;
echo json_encode($arr_result);
}
}
} else {
redirect('/login');
}
}
Model:
public function sugestao($palavraChave)
{
$query = $this->db->query("//select que utilizo");
return $query->result();
}
If I try calling this way in the browser link AnyQuery it returns me the result normally, but the moment I type in the input it does not show the listing as it was done before.
Thank you in advance!