I have a inputText
that I want to autocomplete with a list of words that are read from a bd table using ajax using typeahead.js .
The problem I have is that although by ajax I get all the results that contain the input text, they do not show me all, sometimes I show one, another two ...
The javascript code is as follows:
$('#txtEmpresa .typeahead').typeahead({
highlight: true,
hint:false,
minLength: 3,
},
{
name: 'empresas',
display: 'empresas',
source: function(query, processSync, processAsync) {
return $.ajax({
url: '../autocomplete_empresas',
type: 'GET',
data: {
query: query
},
dataType: 'json',
success: function(empresas) {
return processAsync(empresas);
}
});
},
templates: {
header: '<h3 class="bg-dark bg-font-dark">Empresas</h3>',
suggestion: function (data) {
return '<p>'+ data.nombre + '</p>';
}
}
}
In the browser I see that 5 objects arrive by ajax and if I put suggestion:function(data){console.log}
it shows me for example only two.
Does anyone know why it can be?