How to reload a SELECT in a form, using ajax via jQuery

How to reload a SELECT in a form, using ajax via jQuery

Hello,

firstofall, sorry, i know that it's a simple question (maybe stupid) but i cannot find out how to do.

1) a user on the website popup add an element to the Database using $.post WORKING
2) i want to refresh the SELECT in the form to include his element that the user just added without reload the page. Don't know how to do that.

  1. <select id="wheel" name="wheel">
  2. <?php
  3.  $connection = new DBConnection();
  4.  $requete = "SELECT nomService FROM structures WHERE serviceInterne = 0";
  5. $result = $connection->query($requete);
  6.          while($val = mysql_fetch_array($result)) { 
  7.          $servicesExternes = $val['nomService'];
  8.         print '<option value='.$servicesExternes.'>'.$servicesExternes.'</option>';
  9.          }
  10.          $connection -> end();
  11.         ?>
  12. </select>

And here the .js

  1. $(document).ready(function(){
  2.         $('#valider_ajout_structure').click(function(){  
                
                var nomStructure = $('#nomStructure').val();
                var ajouterStructureInterne = $('#ajouterStructureInterne').val();
                
            
                 if (nomStructure.length == 0)
                 {        
                     $('.jquery').html('<class="erreur">Vous n\"avez pas rentrĂ© le nom de la structure');  
                 }
                 else
                 {  
                   $.post("/Iseult/ajouter/structure.php", { nomStructure : nomStructure, ajouterStructureInterne:ajouterStructureInterne });











  3.                 I guess the code to update the SELECT will be here :p
                 }  
             });  
       
     });







Thanks for your help