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 don't know how to do is 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 ajax with Append.
Any idea to do it.
First do the necessary append to add the TD when you finish the necessary lines you do the:
To give you a headache with the ids "#Centrocost1, #Centrocost2,...." use classes is more optimal.
Greetings.