title: HTML submit form without refresh page and display alert box
body: <p>I want to submit the form to php, then the data will be updated to the database and alert box will be displayed.
  Now, data had update the DB but the alert box didn't show up.
  What is the problem of my code??
  Thanks.</p>
  
  <p>test.html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
      &lt;script&gt;
          function SubmitForm() {
          var category_id = $("#category_id").val();
          var category_name = $("#category_name").val();
          $.post("test.php", { category_id: category_id, category_name: category_name },
             function(data) {
               alert("Finish!");
             });
          }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
      &lt;form action="test.php" method="post"&gt;
          category_id: &lt;input type="text" name="category_id" id="category_id"/&gt;
          category_name: &lt;input type="text" name="category_name" id="category_name"/&gt;
          &lt;input type="button" id="searchForm" onclick="SubmitForm();" value="Send" /&gt;
      &lt;/form&gt; 
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>test.php</p>
  
  <pre><code>&lt;?php
  
  $a = $_POST['category_id'];
  $b = $_POST['category_name'];
  
  
  $link = mysql_connect('localhost','root',''); 
  mysql_select_db("fyp", $link);
  $sql = "INSERT INTO category (CID, Category) VALUES (".
           PrepSQL($a) . ", " .
           PrepSQL($b) . ")";
  
  mysql_query($sql);
  
  function PrepSQL($value)
  {
      // Stripslashes
      if(get_magic_quotes_gpc())
      {
          $value = stripslashes($value);
      }
  
      // Quote
      $value = "'" . mysql_real_escape_string($value) . "'";
  
      return($value);
  }
  ?&gt;
  </code></pre>