javascript - Can't remove div with id using jQuery -


this question has answer here:

after ajax request, want div id disappeard doesn't work. there no error in console log. i've checked condition after ajax request alert() , works remove() function wich doesn't work.

my div (it contains lot of content 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 idea?

in jquery selector-syntax : has special meaning, see here examples: https://api.jquery.com/category/selectors/basic-filter-selectors/ . in example seems part of id-string: '#avion_iddiv:'+avion_id. may have other way of forming id-strings.

sorry! noticed, joe has mentioned point 10 mins ago! did not mean regurgitate post. joe deserves credits answer.


Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -