I have a page with a datatable, in the select event of this table open a modal passing the selected registry id to modal, in the modal I delete this record, shortly after I close the modal and redirect to the page that was previously , but the table is empty, that is, it did not update with the new records.
Table: JavaScript
$('#TabEvolucao').DataTable({
"processing" : true,
"select": true ,
"ajax" : {
"type" : "POST",
"url" : "estrutura/tabevolucao.php",
dataSrc : '',
"data" : function(d){
d.idcliente = vlsidcliente;
d.acao = "select";
}
},
"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"
}
}
});
Sending data from the selected registry to modal: JavaScript
var table = $('#TabEvolucao').DataTable();
table
.on( 'select', function ( e, dt, type, indexes ) {
var rowData = table.rows( indexes ).data().toArray();
//events.prepend( '<div><b>'+type+' selection</b> - '+JSON.stringify( rowData )+'</div>' );
//var dt = JSON.stringify( rowData );
var id = rowData["0"].id;
document.getElementById('idevolucao').value = id;
$('#modalVWEVOLUCAO').data('id', id).modal('show');
} )
Delete button in MODAL JavaScript
$('#btnUpdateYesEVO').click(function () {
var id = $('#myModalUpdateEVO').data('id');
var idevolucao = document.getElementById('idevolucao').value;
var descricaoevolucao = document.getElementById('descricaoevolucao').value;
var boatao = document.getElementById('acaobotaoevolucao').value;
var iduser=$('#iduser').val();
if(boatao == 'DESATIVAR'){
$.post('estrutura/excluirevolucao.php',{
acao:'delete',
id:id,
user_id:iduser
},function(r) {
var m = jQuery.parseJSON(r);
if (m.success) {
$('#myModalUpdateEVO').modal('hide');
toastr["success"](m.msg);
$("#listevolucao").load(location.href + " #listevolucao>", "");//<<<<<< esta aqui o problema
} else {
toastr["error"](m.msg);
$('#myModalUpdateEVO').modal('hide');
}
});
}