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 6252157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:44:49+00:00 2026-05-24T13:44:49+00:00

I cant get this form to submit correctly. If I have the button type

  • 0

I cant get this form to submit correctly. If I have the button type as “submit” it always submits and if I use “button” as the type it never submits, the ajax call brings in the correct values, so even though the if statement follows the correct path but it doesnt seem to matter.

<script type="text/javascript">
$(document).ready(function(){
 $("#submitButton").click(function(e) {
        var un  = $('#username').val();
        $('#mike').html("");       
            $.ajax(
            {              
                type: "POST",
                url: "Utilities/CheckUsername.php",
                data: "un="+ un,
                success: function(data2)
                {                  
                   if(data2=="Username Does Not Exist")
                    {         
                       $("#login2").submit();                   
                    }
                    else
                    {
                        $('#mike').html(data2);
                        return false;                      
                    }                   
                }

            });
             });

             }); 
             </script>
</head>
<body>
      <form name="login" id="login2" method="post" action="dsds.html">
        UserName<input type="text" name="username" id="username"value="">
        <br/>
        Password<input type="text" name="password" id="password" value="">
        <br/>
        Password Again<input type="text" name="passwordagain" id="passwordagain" value="">
        <br/>
        <input type="hidden" name="NewClass" id="NewClass" value="true">
        <br/>
        <input type="submit" name="no" id="submitButton" value="submit">
     </form>
     <span id = "mike"></span>
</body>
</html>

EDIT:
I added the return false here and it works, but why? I am just returning false from the click event

else
            {
                $('#mike').html(data2);

            }                   
        }

    });
     return false;
     });
  • 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-05-24T13:44:49+00:00Added an answer on May 24, 2026 at 1:44 pm

    You just need to return false from your submit event handler. The return false you have in there isn’t performed until after the asynch ajax call is finished.

    Alternatively you can use e.preventDefault() which does the same thing.

    Both methods simply prevent the default behavior, i.e. submitting the form, from occurring.

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

Sidebar

Related Questions

I'm struggling to get a $.ajax call to correctly send some form data to
I have the following JQuery to submit a contact form with jquery ajax. This
I am unable to determine which form submit button is clicked during an Ajax
I have a form with multiple submit buttons. When one of those button is
I'm probably doing something realy stupid but I cant get this to work: var
Revising for php and cant seem to get this to print the values out
I cant find one way to get this value (comment) into json using javascript.
Well since i installed IE 8 i get this error so i cant debug
I cant understand what this warning I get on Xcode is about. Searching for
This is my application's current workflow for user registration. register form ( GET /register

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.