0
I have the following situation, when I enter the data from the database, my table is populated as follows:
And this message appears: "No data available in table", as if the data that are inserted were not for the table.
The HTML code is this:
<table id="dataTable" class="table table-condensed table-hover table-striped table-responsive">
<thead>
<tr>
<th>Código</th>
<th>Nome</th>
<th>CNPJ</th>
<th>E-mail</th>
<th>Responsável</th>
</tr>
</thead>
<tbody></tbody>
</table>
And the java script code is this:
$(document).ready(function() {
$.ajax({
url: 'http://localhost:8080/exemplo',
data: {},
dataType: "json",
cache: false,
success: function (data) {
$.each(data, function (i, val) {
var tr = "<tr>" +
"<td>"+ val.id + "</td>" +
"<td>"+ val.id + "</td>" +
"<td>"+ val.id + "</td>" +
"<td>"+ val.id + "</td>" +
"<td>"+ val.id + "</td>" +
"</tr>";
$(tr).appendTo('tbody');
});
}
});
});
So the table functions like paging and searching also don’t work. But if I enter the data manually into the HTML between the tbody tags the table works normally. Does anyone know what it’s about?
Thanks in advance for the help.
simply Voce has 6 TH tags, but
$.each
is only putting 5 TD inside each TR. I think that might be it– Neuber Oliveira
Hello, I took the test and it makes no difference, the error persists.
– Lucas Borim