0
I have a AJAX that in the 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, ie, when i=0
gets 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>
Gilmar, could you add links to the official documentation to make your response even better
– fernandosavio
Link to the documentation append jquery. http://api.jquery.com/append/
– Gilmar Alonso
I meant edit your answer, but that’s okay. I add.
– fernandosavio