I have a table structure as follows:
<table id="example" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th></th>
<th>Razão Social</th>
<th>CNPJ</th>
<th>CEP</th>
<th>Rua</th>
<th>Cidade</th>
<th>Bairro</th>
<th></th>
</tr>
</thead>
</table>
And in the last <th>
there are control buttons that serve for basic CRUD, view, change, delete, create, throughout this table.
Here is an image of a piece of the table:
AndIhaveafunctionthatIexecutewhenIclickthethirdicon(#disableCompany),tomakeachangeinthedatabase:
$(document).on('click','#disableCompany',function(e){e.preventDefault();varuid=$(this).data('id');$.ajax({url:'disableCompany.php',type:'POST',data:{id:uid},dataType:'html'}).done(function(){$.gritter.add({title:'<iclass="fa fa-exclamation-circle" aria-hidden="true"></i> Empresa desativada com sucesso!',
text: 'A empresa selecionada foi desativada com sucesso! Ela não terá mais acesso ao sistema até que você reative-a novamente.',
class_name: 'gritter-info'
});
setTimeout(function(){
window.location.reload();
}, 5000);
});
});
If the status (1 column) is red (equal to 0 in the data-id attribute), I will send it to the PHP script and then activate (put status 1) and only when I reload the page it will get be seen to change . Can not reload () update dynamically ?
The code of the last <tr>
as requested:
"columnDefs": [
{
"targets": 7,
"data": "",
"render": function (data, type, full) {
return '<a data-toggle="modal" data-target="#infoModal" data-id="' + full[7] + '" id="getCompany" class="blue"><i class="ace-icon fa fa-search-plus bigger-130"></i></a> <a class="red" href="deleteCompany.php?id_Company=' + full[7] + '"><i class="ace-icon fa fa-trash-o bigger-130"></i></a> <a class="orange" data-id="' + full[7] + '" id="disableCompany"><i class="ace-icon fa fa-eye-slash bigger-130"></i></a>';
}
}]