Hello,
I have a function in ajax, in which I do a multi-line removal in an html table.
The function collects several id
that will be deleted, I would like to make a fadeOut('slow')
when the function is executed.
Part of the Table
<tr id="<?php echo $produto['idarquivo']; ?>" >
This id
is already being collected in the ajax
function, I would like to use the effect in the part where the table is removed.
JS Code with the Ajax Function
(I tried to make fadeOut('slow')
run, but I could not (I already tested it in the debugger and the ajax delete function is executed).
$('#btn_delete').click(function(){
if(confirm("Deseja deletar as linhas selecionadas?"))
{
var id = '';
$('.checkbox:checked').each(function(){
id += $(this).val()+',';
});
if(id == '' || id == ',')
{
alert("Selecione uma linha para deletar");
}
else
{
$.ajax({
url:'deletar.php',
type:'POST',
data:{ids:id},
success:function()
{
for(var i=0; i<id.length; i++)
{
$('tr#'+id[i]+'').css('background-color', '#ccc');
$('tr#'+id[i]+'').fadeOut('slow');
}
}
});
}
}
else
{
return false;
}
});
deletar.php
<?php include_once('conexao.php');
$ids = $_POST['ids'];
print_r($ids);
$exp = explode(",", $ids);
foreach($exp as $id){
$query = "DELETE FROM arquivo WHERE idarquivo = '$ids'";
$resultado = mysqli_query($con, $query);
}
?>