1
I have this function to send the array to the php file:
function deletar(){
var ids = []; //arraypara armazenar os id's a serem deletados
$(".colorir").each(function(){ //percorre todos os tr que possui a classe colorir
ids.push($(this).find(".apagar").attr("Id")); //adiciona o id da linha ao array
$(this).remove();
})
$.ajax({
url: './deleteRAD',
type: 'POST',
cache: false,
data: {ids:ids},
error: function(){
},
success: function(result)
{
}
});
//só fazer a chamada para remoção das linhas no php
console.log(ids);
}
The value of ids
sent by ajax
is ["33,Rute"]
.
Then in the file of php
do the delete
:
$partes = explode(',',$_POST["ids"]);
$partes1 = $partes[0];
$partes2 = $partes[1];
$delete = "DELETE FROM centrodb.Alertas WHERE Id='$partes1'";
$result = mysqli_query( $conn, $delete);
if (false === $result) { echo mysqli_error(); }
But do not remove in the database and in the log file of the web server I get the following message: