title: send data from js function to a modal in the same file
body: <p>I have 3 variables declared in a js function and i want to send them to my modal to display their data </p>
  
  <p>js: </p>
  
  <pre><code> function consulter_salle(id)
          {
                 $.ajax({
                  url : "&lt;?php echo site_url('index.php/batiment/list_salle')?&gt;/"+id,
                  type: "POST",
                  dataType: "JSON",
                  success: function(data)
                  {
                     var table_header = "&lt;table&gt;";
                     var table_footer = "&lt;/table&gt;";
                  var html ="";
  
                  for (var row in data)
                  {
                      html += "&lt;tr&gt;&lt;td&gt;"+ data.id+"&lt;/td&gt;&lt;td&gt;"+data.libelle +"&lt;/td&gt;&lt;/tr&gt;";
                  }
  
         $('#modal_list').modal('show'); // show bootstrap modal when complete loaded
                  $('.modal-title').text('Test');
  
  
                  },
                  error: function (jqXHR, textStatus, errorThrown)
                  {
                      alert('Error displaying data');
                  }
              });
  
          }
  </code></pre>
  
  <p>my modal :</p>
  
  <pre><code>&lt;div class="modal fade" id="modal_list" role="dialog"&gt;
        &lt;div class="modal-dialog"&gt;
          &lt;div class="modal-content"&gt;
            &lt;div class="modal-header"&gt;
              &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;&lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;&lt;/button&gt;
              &lt;h3 class="modal-title"&gt;Liste des salles&lt;/h3&gt;
            &lt;/div&gt;
            &lt;div class="modal-body form"&gt;
              &lt;form action="#" id="form" class="form-horizontal"&gt;
  
                &lt;div class="form-body"&gt;
  
                       &lt;/form&gt;
                &lt;/div&gt;
                &lt;div class="modal-footer"&gt;
                  &lt;button type="button" id="btnSave" onclick="save()" class="btn btn-primary"&gt;Save&lt;/button&gt;
                  &lt;button type="button" class="btn btn-danger" data-dismiss="modal"&gt;Cancel&lt;/button&gt;
                &lt;/div&gt;
              &lt;/div&gt;&lt;!-- /.modal-content --&gt;
            &lt;/div&gt;&lt;!-- /.modal-dialog --&gt;
          &lt;/div&gt;
        &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>the data is a list that i sent it by my controller,and it been verified that the data is recieved , but i can't find a way to send it to the modal.
  I wonder what to write in the modal-body section! 
  Thank you .</p>