Problem Deleting Row in SQL Table with Ajax

0

I have a function, trying to delete a row from my sql table, but nothing has happened.

HTML :

<span class="action"><a href="#" id="<?php echo $id; ?>" class="delete" title="Delete">Sim</a></span>

<script src="js/jquery.js"></script>

<script type="text/javascript">
$(document).ready(function()
{
    $('.delete').click(function()
    {
        if (confirm("Tem certeza que deseja excluir?"))
        {
            var id = $(this).parent().parent().attr('id');
            var data = 'id=' + id ;
            var parent = $(this).parent().parent();

            $.ajax(
            {
                   type: "POST",
                   url: "deletar-aguardando.php",
                   data: data,
                   cache: false,

                   success: function()
                   {
                    parent.fadeOut('slow', function() {$(this).remove();});
                   }
             });
        }
    });

    $('table#delTable tr:odd').css('background',' #FFFFFF');
});
</script>

In the deletar-aguardando.php file I have:

include_once('conexao.php');

if($_POST['id'])
{
    $id=($_POST['id']);
    $delete = "DELETE FROM clientes WHERE id='$id'";
    mysqli_query($con, $delete);
}

My file conexao.php is working.

    
asked by anonymous 11.08.2016 / 23:40

1 answer

0

Try substituting where you have var id = $(this).parent().parent().attr('id');

By var id = $(this).attr('id');

    
11.08.2016 / 23:49