I have an AJAX that in success
brings a response
:
$(response).each(function(i) {
alert(response[i]);
$('#tbody').html(
"<tr>" +
"<td>" + response[i].id + "</td>" +
"<td>" + response[i].nome + "</td>" +
"</tr>")
});
My HTML:
<tbody id="tbody"></tbody>
But it is overwriting the data, that is, when i=0
looks like this:
<tbody id="tbody">
<tr>
<td> 1 </td>
<td> Maria </td>
</tr>
</tbody>
when i=1
:
<tbody id="tbody">
<tr>
<td> 2 </td>
<td> João </td>
</tr>
</tbody>
Expected result:
<tbody id="tbody">
<tr>
<td> 1 </td>
<td> Maria </td>
</tr>
<tr>
<td> 2 </td>
<td> João </td>
</tr>
</tbody>