1
I need to delete a record in the database by id, I am displaying my table with the records through ajax and jquery, however I need a button that excludes by the id of the record, I have created the page deleta.php (works) however I can not pass the id to php, follows the ajax that carries the tebela:
$(document).ready(function(){
    $('#tabela').empty(); //Limpando a tabela
    $.ajax({
        type:'post',        //Definimos o método HTTP usado
        dataType: 'json',   //Definimos o tipo de retorno
        url: 'getDados.php',//Definindo o arquivo onde serão buscados os dados
        success: function(dados){
            for(var i=0;dados.length>i;i++){
                //Adicionando registros retornados na tabela
                $('#tabela').append('<tr><td>'+dados[i].nome+'</td><td>'+dados[i].endereco+'</td><td>'+dados[i].telefone+'</td><td><button id="apagar" onload="confirm_delete('+dados[i].id+')">Excluir</td></tr>');
            }
        }
    });
});
$('apagar').click(function(){
                    window.location.href='excluir.php?id='+dados[i].id;
                })
Forehead
window.location.href='excluir.php?id=' + this.id;for thethisis the button clicked on this function.– Sergio
did not work, I have to pass the id tbm in $('#table')??
– caio