0
I have the following function that returns data from a query in the database and stores in json format in the msg variable.
$.ajax({
type: 'POST',
dataType: 'html',
url: page,
data: {idtabela: idtabela},
success: function (msg) {
msg = $.parseJSON(msg);
}
});
In my front-end file, I need to popular this table. I am using the Datatables plug
<table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th>Cliente</th>
<th style="width: 50px">Carro</th>
<th style="width: 50px">Data</th>
<th style="width: 150px">Ações</th>
</tr>
</thead>
<tbody>
<tr class="odd gradeX">
<td>> </td>
<td> </td>
<td> </td>
<td style="text-align: center">
<a class="btn btn-primary btn-sm" href="edit.php?id=1" role="button">Editar</a>
<input type="button" value="Excluir" class="btn btn-danger btn-sm""/>
</td>
</tr>
</tbody>
</table>
jquery function for the datatables plugin
$(document).ready(function() {
$('#dataTables-example').DataTable({
language:{
url: '../includes/datatable_ptbr.json'
},
responsive: true
});
});