After an Ajax request, I want that the div with the ID disappeard but it doesn't work. There is no error in the console log. I've checked the condition after the ajax request with an alert()
and it works so this is the remove()
function wich doesn't work.
My div (it contains a lot of content like divs)
<div class="div_avion" <?php echo ($demandePHP==true)?'id="avion_idDIV:'.$dataPHP['avion_id'].'"':'';?> <?php echo ($demandePHP==false)?'style="display:none;"':'';?>>...</div>
JS
$(document).ready(function(){
$(document).on('click', '.button-trash', function() {
if($(this).is(".avion_bdd"))
{
var avion_id = $(this).attr('id').replace("avion_id:", "");
var result = confirm("Etes-vous sûr de vouloir supprimer cet avion ?");
if (result) {
$.ajax({
url : '<?php echo 'http://'.$_SERVER[HTTP_HOST].'/scripts/deleteavionflottehub.php';?>',
type : 'POST', // Le type de la requête HTTP, ici devenu POST
data : 'avion_id='+avion_id,
dataType : 'html',
success : function(resultat, statut){
if(resultat=='OK')
{
$('#avion_idDIV:'+avion_id).remove();
}
},
error : function(resultat, statut, erreur){
},
complete : function(resultat, statut){
}
});
}
}else{
$(this).parent().parent().parent().parent().parent().remove();
}
});
});
Have you an idea?