Home > Blockchain >  I wish to send the result of request Ajax on my form HTML - i have the data in 'response.labo&#
I wish to send the result of request Ajax on my form HTML - i have the data in 'response.labo&#

Time:08-09

i wish to send my data from ajax result to my form HTML. The Data is in the 'response.labo' and i wish to send all to my Form. Thanks for our helps

here is my code : The Ajax code :

              $.ajax({
              type: "POST",
              url: "/controller/edit_labo.php",
              data: {
                  action: "editer",
                  dm_data
                
              },
              success: function (response) {
                DM_LIST = response.labo;
                console.log(response.labo);

The HTML code :

<div >
    <div >  
        Matriculle : 
    </div>
    <div >  
        <input type="text"  name="matriculle" placeholder="Matriculle" id='matriculle'>
    </div>
</div>
<br>
<div >
    <div >  
        Prénom : 
    </div>
    <div >  
        <input type="text"  name="prenom" id="prenom" placeholder="Prénom" autocomplete="off">
    </div>
</div>

This is the form that i wish to send all my data

CodePudding user response:

$("#matriculle"); // here is the form field find by id

.val(value); //here is the method to set the field value

response.labo //here is your response, as you didn't provide the structure, I guess you have some properties inside it.

success: function (response) {
      DM_LIST = response.labo;
      console.log(response.labo);

      $("#matriculle").val(response.labo.propertyname);
}
  • Related