I have the following table:
<body>
<table id="datas" align="center">
<thead>
<tr>
<th>Id</th>
<th>Nombre</th>
<th>Edad</th>
</tr>
</thead>
<tbody id="cuerpo">
</tbody>
</table>
</body>
I have a script that brings me data from a BD to fill in the table:
$("body").ready(function () {
$.ajax({
url: "index.aspx/listado",
method: "POST",
//data: JSON.stringify(datos),
//async: true,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (respuesta) {
console.log(respuesta.d);
//LENAR BODY DE TABLE
}
});
});
The following is coming to me in respuesta.d
:
[{"id":1,"nombre":"Victor","edad":28},
{"id":2,"nombre":"Vix","edad":15},
{"id":3,"nombre":"Viti","edad":30},
{"id":4,"nombre":"Sandro","edad":16},
{"id":5,"nombre":"Carmen","edad":19},
{"id":6,"nombre":"Pedro","edad":20}]
How can I put this data in body
of the table.