title: Executing a PHP file from a jQuery / AJAX request
body: <p>I'm making a chat function where staff members with the appropriate privileges can delete a line that has been posted to the chat room.</p>
  
  <p>I'd like this function to work without refreshing the page, but I can't seem to get the jQuery / AJAX part of it right? Nothing happens at all.</p>
  
  <p>As a jQuery newbie I was hoping that someone could point out the line that I'd have to look at?</p>
  
  <p>a href that needs to be clicked to delete line:</p>
  
  <pre><code>for (var i in json.lines) {
      lines.push("[&lt;a class='delete' href='#' data-lineID='" + json.lines[i].id + "'&gt;x&lt;/a&gt;] " + json.lines[i].user + json.lines[i].divide + " " + json.lines[i].message);
  }
  </code></pre>
  
  <p>jQuery:</p>
  
  <pre><code>$('a.delete').on('click', function(event) {
  var id = $(this).data('lineID');
  
      /* Request to .php file */
      var request = $.ajax({
      url: "/communications/chat.php?page=delete",
      type: "POST",
      data: { id : id },
      dataType: "html"
      });
  
    event.preventDefault();
    return false;
  </code></pre>
  
  <p>});</p>
  
  <p>Part of the PHP script to execute:</p>
  
  <pre><code>case 'delete' :
  
  if(isset($_POST['id']) &amp;&amp; !empty($_POST['id'])) {
      $id = $_POST['id'];
  
      try {
          $query = $udb-&gt;prepare("UPDATE `chat_lines` SET `deleted` = '1' WHERE `id` = ?");
          $query-&gt;bindValue(1,$id);
          $query-&gt;execute();
      } catch (Exception $e) {
          die($e-&gt;getMessage());
      }
  }
  
  break;
  </code></pre>
  
  <p>Any help is appreciated :)</p>