title: Sending HTML code to ajax
body: <p>I need to send this HTML block as a response(or request?) to ajax script, probably I also need this php part... Basically i want to open a modal box with data generated from variable that i am getting from JS, and when a tried to generate my modal outside of ajax it didnt update well. </p>
  
  <pre><code>if(!empty($_SESSION['modalBoxID'])){
      $sql = "SELECT * FROM vehicle WHERE vehicle.id='{$_SESSION['modalBoxID']}'";
      $sqlquery = $db-&gt;query($sql);
      $_SESSION['modalBoxID'] = NULL;
  }
  ?&gt;
  
  
   &lt;div class="modal-body display-content"&gt;
              &lt;div class="container-fluid"&gt;
              &lt;?php while($details = mysqli_fetch_assoc($sqlquery)) : ?&gt;
  
  
                  &lt;div class="col-md-4"&gt;&lt;img src=&lt;?php echo $details['image'];?&gt; class="image-responsive"&gt;
  
                  &lt;div class="col-sm-6"&gt;
                      &lt;form action="add_cart.php" method="post"&gt;
                      &lt;div class="form-group"&gt;
                          &lt;label for="quantity"&gt;Quantity:&lt;/label&gt;
                          &lt;input type="text" class="form-control" id="quantity" name="quantity"&gt;
                      &lt;/div&gt;
                      &lt;/form&gt;
                  &lt;/div&gt;
                  &lt;div class="col-sm-6"&gt;
                      &lt;br/&gt;
                      &lt;button type="button" class="add-to-basket btn btn-success" &gt;ADD TO CART&lt;/button&gt;
                  &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="col-md-1"&gt;&lt;/div&gt;
                  &lt;div class="col-md-7" id="desc"&gt;
                      &lt;p&gt;&lt;b&gt;Model:&lt;/b&gt; &lt;?php echo $details['model'];?&gt;&lt;/p&gt;
                      &lt;p&gt;&lt;b&gt;Engine:&lt;/b&gt;  &lt;?php echo $details['engine'];?&gt;&lt;/p&gt;
                      &lt;h4&gt;Description&lt;/h4&gt;
                      &lt;p&gt;&lt;?php echo $details['description'];?&gt;&lt;/p&gt;
                      &lt;hr&gt;
                      &lt;hr&gt;
                  &lt;/div&gt;
  
              &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="modal-footer"&gt;
            &lt;button type="button" class="btn btn-default" data-dismiss="modal"&gt;Close&lt;/button&gt;
          &lt;/div&gt;
    &lt;?php endwhile; ?&gt;
  &lt;/div&gt;      
  </code></pre>
  
  <p>Here is JS script that i need to send it to</p>
  
  <pre><code>$(document).ready(function(){
  // Otevre modal
  $('.show-modal').click(function(){
      var product_id = $(this).attr('data-id');
          $.ajax({
          type: 'POST',
          cache: false,
          data: {modalID : product_id},
          url: 'includes/getID.php', // tomuto souboru predas idecko produktu, zapises do kosiku atd.
          success: function(data) {
              $('.modal-body').html(data)
              $("#itemBox").modal('show');
              // treba nejaka hlaska, ze byl pridan do kosiku
          }
      });
  
  
      // kod co otevre modal, mkrni na bootstrap manual jak je otevira nebo si otevreni nadefinuj sa
      //$('.product_id').val(productID);
  });
      $(document.body).on('hidden.bs.modal', function () {
            $("#itemBox").removeData('bs.modal');
          });
  </code></pre>