title: Jquery ajax request not working
body: <p>I've used the same code before, I've checked and checked, and there's no error. It seems that somehow this piece of code is not doing what it's supposed to. And I don't know why. Please help.</p>
  
  <p>The ajax code seem to not perform an ajax request, but rather submits a normal HTTP get/post request depending on what the form is set to in the HTML. Which mean the page keeps refreshing. It seems that the success function doesn't even get called. I've checked that the rest of the code is working up until the line <strong>$.ajax({</strong> where it refreshes the page. Could it be the way that I set up the form? Notice that I don't have a submit button because the form sends different action to the server depending on which button is pressed.</p>
  
  <p>Here is the HTML code:</p>
  
  <pre><code>&lt;form id="frmVerify" name="frmVerify" method="post"&gt;
  &lt;p&gt;Your account has not been verified. You must verify your email to continue logging into your account.&lt;/p&gt;
  &lt;p&gt;A verification token was sent to your email address, &lt;strong id="username" name="username"&gt;&lt;?php echo $_SESSION['username']; ?&gt;&lt;/strong&gt;. Note that this token expires after 24 hours of issue.&lt;/p&gt;
  &lt;p&gt;Please check your email to retrieve this token:&lt;/p&gt;
  
    &lt;p&gt;
    &lt;input type="text" name="token" id="token" /&gt;
    &lt;button name="action" id="verify" value="&lt;?php echo ACT_VERIFY; ?&gt;"&gt;Verify&lt;/button&gt;
    &lt;/p&gt;
    &lt;p&gt;You can also: &lt;/p&gt;
  &lt;p&gt;
    &lt;button name="action" id="send" value="&lt;?php echo ACT_SEND_TOKEN; ?&gt;"&gt;Send another token&lt;/button&gt;&lt;br /&gt;
  
    &lt;button name="action" id="change" value="&lt;?php echo ACT_CHANGE_EMAIL; ?&gt;"&gt;Change Email&lt;/button&gt;&lt;br /&gt;
  
    &lt;button name="action" id="delete" value="&lt;?php echo ACT_DELETE_ACCOUNT; ?&gt;"&gt;Delete Account&lt;/button&gt;
  &lt;/p&gt;
  &lt;p&gt;
    &lt;input type="hidden" name="requester" id="requester" value="Verification" /&gt;
  &lt;/p&gt;
  &lt;p&gt;&lt;a href="logout.php"&gt;Log out&lt;/a&gt;&lt;/p&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Here is the JQUERY code:</p>
  
  <pre><code>function submitForm(action){
      var username = $("#username").html();
      var token = $("#token").val();
      var requester = $("#requester").val();
      if(validateLogin()){
          $.ajax({
              type: "post",
              url: "verification.php",
              data: "username="+username+"&amp;token="+token+"&amp;action="+action+"&amp;requester="+requester,
              success: function(data) {
                  try{
                      var jsonObj = $.parseJSON(data);
                      processOutput(action, jsonObj);
                  }catch(e){
                      $("#output").html("PHP module returned non JSON object: &lt;p&gt;"+data+"&lt;/p&gt;");
                  }//try
              }//success function
          });//ajax
      }else{
          alert("Please fill UserName &amp; Password!");
          return false;
      }//if validate
  }
  
  $(document).ready(function(){
  
  $("#verify").click(function(){
      var action = $(this).val();
      submitForm(action);
  });
  
  $("#send").click(function(){
      var action = $(this).value();
      submitForm(action);
  });
  
  $("#change").click(function(){
      var action = $(this).value();
      submitForm(action);
  });
  
  $("#delete").click(function(){
      var action = $(this).value();
      submitForm(action);
  });
  });
  </code></pre>