I am assigning the "autocomplete" function of jQuery to an input but it does not show the results.
The data is collected from the BD through a PHP function using the post method. Going through the trace I verified that the data is received, converted into an array of strings and passed to a variable, which is called in the source of the autocomplete function.
I pass the jQuery code:
$.post("../../events_front_end/autocomplete_events/",{'autocomplete':true},function(data,status){
//console.log(data);
var json=JSON.parse(data);
var name_events=json.band_name;
//AQUI ENTRA
console.log(name_events);
var suggestions =new Array();
for (var i =0; i<name_events.length; i++){
suggestions.push(name_events[i].band_name);
}//end of for
//AQUI ENTRA
console.log(suggestions);
$("#keyword").autocomplete({
source: suggestions,
minLength:1,
select:function(event, ui){
//AQUI NO ENTRA
console.log("Estoy en select");
var keyword =ui.item.label;
count_event(keyword);
}
});
}).fail(function(xhr){
$("#results").load("../../events_front_end/view_error_false/",{'view_error':false});
$('.pagination').html('');
reset();
});//End of $.post autocomplete
Could someone guide me about where the error might be? I have made several tests without success. Thanks in advance.