I am trying to insert the elements in a table, but when showing the data object, the undefined message is appearing
How to pass this date object to the table?
The other objects are ok, I just have a problem with the data object
JSON:
[
{
tipo: "O",
numero: "001",
data: { year: 2019, month: 4, day: 18 },
prazo: 0,
documento: "4600530888",
},
];
$.ajax({
url: 'buscaTextoAditivos.action', // action to be perform
type: 'POST', //type of posting the data
data: { linhaSelecionadaJson: jsonHide }, // data to set to Action Class
dataType: 'json',
success: function (data) {
var indices = ['Tipo', 'Numero', 'Data', 'Prazo', 'Document']
var table = $("<table>")
var thead = $('<thead>')
for (const index of indices) {
$('<th>' + index + '</th>').appendTo(thead)
}
var tbody = $('<tbody>')
for (const item of data) {
var tr = $('<tr>')
for (const index of indices) {
$('<td>' + item[index] + '</td>').appendTo(tr)
}
tr.appendTo(tbody)
}
tbody.appendTo(table)
$("#loaderMaiorDemandante").hide();
table.appendTo('#records_table')
