0
I can’t find the error, simply do not populate the table:
ERROR
Datatables Warning: table id=Tabevolucao - Invalid JSON Response. For more information about this error, Please see http://datatables.net/tn/1
AJAX
$('#TabEvolucao').DataTable({
"processing" : true,
"ajax" : {
"type" : "POST",
"url" : "estrutura/tabevolucao.php",
dataSrc : '',
"data" : function(d){d.idcliente = 127;}
},
"columns" : [ {"data" : "id"},
{"data" : "data"},
{"data" : "descricao"},
{"data" : "nome"},
{"data" : "ativo"}
],
"aaSorting": [[1,'asc']],
"iDisplayLength": 7,
"bFilter": true,
"aaSorting": [[1,'asc']],
"language": {
"sEmptyTable": "Nenhum registro encontrado",
"sInfo": "Mostrando de _START_ até _END_ de _TOTAL_ registros",
"sInfoEmpty": "Mostrando 0 até 0 de 0 registros",
"sInfoFiltered": "(Filtrados de _MAX_ registros)",
"sInfoPostFix": "",
"sInfoThousands": ".",
"sLengthMenu": "_MENU_ resultados por página ",
"sLoadingRecords": "Carregando...",
"sProcessing": "Processando...",
"sZeroRecords": "Nenhum registro encontrado",
"sSearch": "Pesquisar",
"oPaginate": {
"sNext": "Próximo",
"sPrevious": "Anterior",
"sFirst": "Primeiro",
"sLast": "Último"
},
"oAria": {
"sSortAscending": ": Ordenar colunas de forma ascendente",
"sSortDescending": ": Ordenar colunas de forma descendente"
}
}
});
PHP
<?php include("../includes/config.php");
if ($_POST)
{
$id = (int) $_POST['idcliente'];
if ($_POST['acao'] == 'select' && is_int($id))
{
$select = "select E.id,E.data,E.descricao,U.nome,E.ativo FROM evolucao as E ";
$select .= "inner join usuarios as U on (U.id=E.id_usuario) WHERE E.id = ".$id;
$rs = $con->prepare($select);
if($rs->execute())
{
if($rs->rowCount() > 0)
{
$data = array();
while($row = $rs->fetch(PDO::FETCH_OBJ))
{
$data[] = array('success' => '1',
'id' => $row->id,
'data' => $row->data,
'descricao' => $row->descricao,
'nome' => $row->nome,
'ativo' => $row->ativo,
'msg' => 'Tudo certo!'
);
}
}
}
}
}
else
{
$data = array('success' => '0', 'msg' => 'Ocorreu um erro, não achamos nada!');
}
echo json_encode($data);
ERROR
DataTables warning: table id=TabEvolucao - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1
Thanks @Virgilio Novic for the help, but there is still a problem, note that I need to pass a parameter to php, already tried but even this rolling. I have a fnc that searches this id "var idcliente = buscarcliente();",
– Jefferson Meireles
@Jeffersonmeireles missed a glance at the documentation on the link: https://datatables.net/examples/server_side/custom_vars.html and made an edition to illustrate!
– novic
not this one, I’ve tried to use the documentation, but something I’m doing wrong. does not bring record, even adding a fixed value in the parameter, I made an edit
– Jefferson Meireles
@Jeffersonmeireles if you edited did not pay attention to the code I put, and other thing often the problem can not be reproduced, is a local problem.
– novic
You’re right, I found the problem, it was my lack of attention.
– Jefferson Meireles
more help on this table, now I want to get the value of one of the table row fields, I need to open a modal passing this value.
– Jefferson Meireles
@Jeffersonmeireles if: https://datatables.net/extensions/responsive/examples/display-types/bootstrap-modal.html you need to open another question, each question and its answers, simply open another question and enter the correct context for it!
– novic