I want to refresh a table when $(.excluir) is clicked. The table is load from php data. When I click the button, the php code executes, and I delete the data from the database.
But I want to refresh the content of the table. So, I tried to call the function again completeTable();, but it didn't work.. The alert appears, but the table doesn't refresh.
function completeTable(){
$.post("completa_tabela.php", {cd_turma: $('#turma').val()}, function(data){
data = jQuery.parseJSON(data);
$.each(data.json, function(){
var button = "<button type='button' class='excluir' value='" + this['codigo'] + "'>X</button>";
$('#' + this['dia_hora']).html(this['nome'] + button);
});
$('.excluir').click(function(){
$.post("altera_horario.php", {excluir: true, cd_horario: $(this).val()}, function(){
alert("$('excluir').click");
completeTable();
});
});
});
}
How can I do that?