Remove ajax log without refresh

1

I have a code in ajax to remove rows from a table, but to delete, I have to click the delete button and give an f5 so that the record is deleted in the current code. I tried to do some forms presented in some posts here, but I could not get them to exclude the registry without giving reaload on the page. Can anyone help me?

function removeTr(id, callback){

    $.ajax({
        url: '/projetophp/controllers/controller-cliente.php',
        dataType: 'json',
        type: 'GET',
        data: {
            requisicao: "excluirClientes",
            id:id
        },

        success: function(){
            callback(); 
        }

    });
};

    $(document).ready(function(){

        /*Função para pegar os registros no banco de inserir na página*/
        $.ajax({
            url: '/projetophp/controllers/controller-cliente.php',
            dataType: 'json',
            type: 'GET',
            data: {
                requisicao: "listarClientes"
            },
            success: function(result) {
                if(result){
                    var $cliente = $("#tabela tbody"),
                    options = "" ;
                    $.each(result, function( index, value ) {
                        options += ("<tr><td>"  + value.id + "</td><td>"  + value.cliente + "</td><td>" + value.email + "</td><td>"+ value.dominio +"</td><td>" + value.rds +"</td><td>"+ value.stack +"</td><td><button type='button' class='btn-editar btn btn-primary'>Editar</button><button type='button'  value='delete' data-id='"+ value.id +"' class='btn-excluir btn btn-danger' data-toggle='modal'>Excluir</button></td></tr>");
                    });
                    $cliente.append(options);

                    /*Função para remover tr*/
                    $('.btn-excluir').on('click', function(){
                        event.preventDefault();
                        var $this = $(this);
                        removeTr($this.data('id'), function(){
                            $this.closest('#tabela tr').remove();


                        });
                    });
                }
            }

        });
    
asked by anonymous 30.09.2016 / 22:23

1 answer

0

panterA, the event was just to test and I just forgot to take it, the problem was that I was giving a var_dump in control and with this I was not executing the callback .. Thanks!

    
03.10.2016 / 17:33