I have this AJAX
$.ajax({
type: 'POST',
url: "libreria.php?cmd=" + comando,
dataType: 'json',
async: false,
data: params,
headers: {
"accept": "application/json",
},
}).done(function (result3){
respuesta4 = result3;
var totalCC = listccostos;
var listccostos2 = [];
for(var i = 0; i < respuesta4.length; i++)
{
var TCcostos = respuesta4[i];
for(var j = 0; j < totalCC.length; j++)
{
if(totalCC[j].value == respuesta4[i].CentroCosto)
{
listccostos2.push(totalCC[j]);
console.log(listccostos2);
//aqui va el append
}
}
}
}).fail(function(xhr){
console.log('error', xhr);
});
What it does is bring me information from the database
Now what I need and I do not know how to do is to this td
cols += '<td> <input class = "c_costos c_validar" id="CentroCosto' + counter2 + '" size="20" autocomplete="off" > </td>';
I need to add this
$("#CentroCosto" + counter2).autocomplete({source: listccostos2, minLength: 0}).focus(function() { $(this).autocomplete('search', $(this).val())});
from the ajax with Append.
Some idea to do it.