title: Query not running when I click delete button even though .success says it worked
body: <p>I have made a model that is called when I click on delete from a toggle down menu. It then gives a list of data that I can delete by clicking the button next to them. But for some reason I can't figure out when the page reloads nothing is deleted. I added an alert 'success' after the success in the javascript. This alert is called but the data is not deleted. The bootstrap and jQuery links are in the index page which all work perfect. This problem has be dumbfounded and if anyone can shed any light on it I'd greatly appreciate it.</p>
  
  <p>This is the html:</p>
  
  <pre><code>&lt;div class="modal fade" id="delete_comment" role="dialog"&gt;
    &lt;div class="modal-dialog"&gt;
      &lt;div class="modal-content"&gt;
        &lt;div class="form-horizontal" role="form"&gt;
          &lt;div class="modal-header"&gt;
            &lt;h4&gt;Delete comments&lt;/h4&gt;
          &lt;/div&gt;
          &lt;div class="modal-body"&gt;
            &lt;?php $comment_array = comments::get_comments($username); ?&gt;
  
            &lt;?php if(isset($comment_array) &amp;&amp; is_array($comment_array)): ?&gt;
  
            &lt;?php
              foreach ($comment_array as $key =&gt; $comment):
              foreach($comment as $key2 =&gt; $comment2):
  
              $max = count($comment_array);
              $i=1;
  
              while($i&lt;=$max):
            ?&gt;
  
            &lt;?php
              $comment_id = $comment2-&gt;id;
              $comment_name = $comment2-&gt;comment_name;
              $comment_type = $comment2-&gt;comment_type;
            ?&gt;
  
            &lt;form class="comment_delete_area_wrapper" action="" method="post"&gt;
              &lt;div class="comment_delete_wrapper"&gt;
                &lt;ul&gt;
                  &lt;li class="comment_delete_comments"&gt;
                    &lt;?php echo $comment_type ?&gt; : &lt;?php echo $comment_name; ?&gt;
                  &lt;/li&gt;
                &lt;/ul&gt;
  
                &lt;div class="comment_delete_button_wrapper"&gt;
                  &lt;input type="submit" id="&lt;?php echo $comment_id; ?&gt;"
                         class="btn btn-danger comment_delete_button" value="Delete"/&gt;
                &lt;/div&gt;
                &lt;br&gt;
                &lt;hr&gt;
                &lt;input type="hidden" value="&lt;?php echo $comment_id; ?&gt;"
                       id="comment_delete_id" name="comment_delete_name"/&gt;
              &lt;/div&gt;
            &lt;/form&gt;
            &lt;?php $i++; ?&gt;
            &lt;?php endwhile;?&gt;
            &lt;?php endforeach; ?&gt;
            &lt;?php endforeach;?&gt;
            &lt;?php endif; ?&gt;
          &lt;/div&gt;
  
          &lt;div class="modal-footer"&gt;
            &lt;a class="btn btn-default" data-dismiss="modal"&gt;Close&lt;/a&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And here is the PHP code for the classes. The comments are all drawn from the database perfect and appear perfect. The problem is deleting them.</p>
  
  <pre><code>&lt;?php
  
  class Comments{
  
      public static function delete($cl_id)
  {
  
  
      $db = new PDO('mysql:host=localhost;dbname=comment;charset=utf8', 'root', '');
      $stmt = $db-&gt;prepare("DELETE FROM `comments` WHERE id = :cl_id");
  
      $stmt-&gt;bindParam(':cl_id', $cl_id);
      if ($stmt-&gt;execute()) {
          return true;
      } else {
          return null;
      }
  }
  
  }
  </code></pre>
  
  <p>And the javascript:</p>
  
  <pre><code>$(document).ready(function(){
  add_delete_handlers();
  });
  
  function add_delete_handlers(){
  $('.comment_delete_button').each(function(){
      var btn = this;
      $(btn).click(function(){
  
          comment_delete(btn.id);
  
      });
  });
  }
  
  function comment_delete(_comment_id){
  
  $.post('comment_area_ajax/comment_delete.php', {
          task: 'comment_delete',
          comment_id: _comment_id
      }
  ).success(function(data){
          alert('Success');
          $('#_' + _comment_id).detach();
      });
  
   }
  </code></pre>
  
  <p>And lastly the code to be called by the AJAX:</p>
  
  <pre><code>&lt;?php
  if(isset($_POST['task']) &amp;&amp; $_POST['task'] =='comment_delete') {
  require_once '../comment_area_sql/models/comment_delete_model.php';
  require_once '../comment_area_sql/models/comments.php';
  
      if(class_exists('Comments')){
  
            if(Comments::delete($_POST['comment_id'])){
                  echo 'true';
  }else{
                  echo 'false';
  }
  
  ?&gt;
  </code></pre>