Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8362009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:50:21+00:00 2026-06-09T11:50:21+00:00

I’ve used the same code before, I’ve checked and checked, and there’s no error.

  • 0

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.

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 $.ajax({ 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.

Here is the HTML code:

<form id="frmVerify" name="frmVerify" method="post">
<p>Your account has not been verified. You must verify your email to continue logging into your account.</p>
<p>A verification token was sent to your email address, <strong id="username" name="username"><?php echo $_SESSION['username']; ?></strong>. Note that this token expires after 24 hours of issue.</p>
<p>Please check your email to retrieve this token:</p>

  <p>
  <input type="text" name="token" id="token" />
  <button name="action" id="verify" value="<?php echo ACT_VERIFY; ?>">Verify</button>
  </p>
  <p>You can also: </p>
<p>
  <button name="action" id="send" value="<?php echo ACT_SEND_TOKEN; ?>">Send another token</button><br />

  <button name="action" id="change" value="<?php echo ACT_CHANGE_EMAIL; ?>">Change Email</button><br />

  <button name="action" id="delete" value="<?php echo ACT_DELETE_ACCOUNT; ?>">Delete Account</button>
</p>
<p>
  <input type="hidden" name="requester" id="requester" value="Verification" />
</p>
<p><a href="logout.php">Log out</a></p>
</form>

Here is the JQUERY 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+"&token="+token+"&action="+action+"&requester="+requester,
            success: function(data) {
                try{
                    var jsonObj = $.parseJSON(data);
                    processOutput(action, jsonObj);
                }catch(e){
                    $("#output").html("PHP module returned non JSON object: <p>"+data+"</p>");
                }//try
            }//success function
        });//ajax
    }else{
        alert("Please fill UserName & 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);
});
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:50:23+00:00Added an answer on June 9, 2026 at 11:50 am

    The reason it is behaving like a normal post is that a button element is a submit type by default so it’s posting before the javascript is finished executing. Change your html button to the following:

    <button type="button" name="action" id="verify" value="<?php echo ACT_VERIFY; ?>">Verify</button>
    

    There may be plenty more to fix with your code but the question was focused on why it was performing a post rather than an ajax post.

    Here is a jsfiddle demonstrating the change. — http://jsfiddle.net/GSVdQ/1/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am doing a simple coin flipping experiment for class that involves flipping a
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I need a function that will clean a strings' special characters. I do NOT
I used javascript for loading a picture on my website depending on which small
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.