title: PHP : return html in $.ajax
body: <p>I am trying to return HTML through <code>$.ajax</code>, this is my code: </p>
  
  <pre><code> $(document).ready(function() {
  
      $(".click").on('click',function() {                
        var id= $(this).attr("data-id"); 
  
        $.ajax({     
          type: "POST",
          url: "getevents.php", 
          data: {id:id}, 
          dataType: "html",                  
          success: function(response){                    
              alert(response);
              $('.headimg').html(response);
          }
       });
   })}) 
  </code></pre>
  
  <p><strong>My PHP code:</strong> </p>
  
  <pre><code> $singleevent = mysqli_query($link, "SELECT `content` FROM `events` WHERE `id` 
  = $id") ;
  if(!$singleevent){
      echo mysqli_error();
  }
  else {
  
  $result = mysqli_fetch_array($singleevent); 
   echo $result; 
  }
  </code></pre>
  
  <p><strong>Link to be clicked:</strong> </p>
  
  <pre><code>&lt;a class='click' data-id='&lt;?=$rows["id"];?&gt;'&gt;&lt;?=$rows['title'];?&gt;&lt;/a&gt;
  </code></pre>
  
  <p>In alert() this is what I get <strong>Array</strong></p>
  
  <p>If I do print_r() instead of echo this is what I get </p>
  
  <pre><code> [0] =&gt; &lt;div class='row'&gt;
    &lt;div class='col-sm-12'&gt;
     &lt;img src='img/img.png' class='img-responsive'&gt;
    &lt;/div&gt;
    &lt;div class='col-xs-12'&gt;
     &lt;p&gt; October 14th  | All Day&lt;/p&gt;
  
    &lt;/div&gt;
  
  &lt;/div&gt;
      [content] =&gt; &lt;div class='row'&gt;
    &lt;div class='col-sm-12'&gt;
     &lt;img src='img/img.png' class='img-responsive'&gt;
    &lt;/div&gt;
    &lt;div class='col-xs-12'&gt;
     &lt;p&gt; October 14th  | All Day&lt;/p&gt;
  
    &lt;/div&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>How to I put it in HTML rather than array? </p>