0
Good afternoon, everyone,
I have a search field where I give "suggestions" of what to type, based on what I have registered in my database. The same was working perfectly, but it stopped working and I can’t 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 test call this way in the browser http://localhost/articles/sugestao? term=Profanity it returns the result normally, but at the time I type in the input it does not show the listing as it was done before.
Thanks in advance!
didn’t work this way :/
– David Santos
Could you tell what happens? So we can see if a lolusion better
– Erlon Charles
Thanks for the help... with this code he gave me he doesn’t even bring results, when I try to type something he doesn’t throw me anything in the Chrome console, with what is it brings me the request in the console and if I access the URL it creates it returns me the results it just does not display below the input these results.
– David Santos
@Davidrodrigues I understand I’ll do some tests
– Erlon Charles