title: trying to add ajax request html to page source
body: <p>I'm working on a project using ajax and PHP, my problem is when I add HTML markup with ajax it's not showing in page source and that preventing my from making another request to delete this markup and the only way that makes my delete it redirect to the same page. </p>
  
  <p>this is my markup code: </p>
  
  <pre><code>&lt;div class="card"&gt;
  
      &lt;div class="card-content"&gt;
          &lt;form&gt;
              &lt;div class="input-field"&gt;
                &lt;textarea id="textarea1" class="materialize-textarea"&gt;&lt;/textarea&gt;
                &lt;label for="textarea1"&gt;Type something here&lt;/label&gt;
              &lt;/div&gt;
          &lt;/form&gt;
      &lt;/div&gt;
      &lt;div class="card-action"&gt;
          &lt;button id="submit" class="btn waves-effect waves-light" type="submit" disabled&gt;Submit&lt;/button&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div id="cards--wrapper"&gt;
  &lt;?php  
      $query = "SELECT * FROM messages ORDER BY id DESC";
  
      $retrieve_posts_query = mysqli_query($connection, $query);
  
      while($row = mysqli_fetch_assoc($retrieve_posts_query)){
          $content_id = $row['id'];
          $post_content = $row['posts'];
          $post_date = $row['date'];
          $post_date = strtotime($post_date);
          $post_date = date('j F, Y', $post_date);
  
  
  
  ?&gt;
      &lt;div class="card" data-id = "&lt;?php echo $content_id; ?&gt;"&gt;
      &lt;a class="btn-large waves-effect waves-light red right delete"&gt;+&lt;/a&gt;
          &lt;div class="card-content"&gt;
              &lt;?php echo $post_content; ?&gt;
              &lt;span&gt; &lt;?php echo $post_date; ?&gt; &lt;/span&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;?php } ?&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and this is my ajax code :</p>
  
  <pre><code>window.onload = function(){
  
      $('#textarea1').keyup(function(){
          var messageInput = $(this).val();
          if( messageInput !== '' ){
              $('#submit').attr('disabled', false);
          }else {
              $('#submit').attr('disabled', true);
          }
      });
  
      $('#submit').on('click', function(){
          retrieveData();
          return false;
      });
  
      function retrieveData(){
          var messageInput = $('#textarea1').val();
          $.ajax({
              url: 'server.php',
              type: 'POST',
              data: {
                  message : messageInput
              },
              success: function(data) {
                  $('#cards--wrapper').prepend(data);
                  $('#textarea1').val('');
                  $('#submit').attr('disabled', true);
                  window.location.href = 'index.php';
              }
          });
      }
  
      $('.delete').on('click', function(e){
          e.preventDefault();
          var that = $(this);
          var cardID = that.parent().data('id');
          var el = that.parent();
          $.ajax({
              url: 'delete.php?delete='+ cardID +'',
              type: 'GET',
              success: function(){
                  el.remove();
              }
          });
  
      });
  }
  </code></pre>