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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:22:38+00:00 2026-05-28T04:22:38+00:00

I have a form: <form name=emailform id=emailform onsubmit=emailSubmit() method=post><div> <input type=text id=email name=email value=>

  • 0

I have a form:

 <form name="emailform" id="emailform" onsubmit="emailSubmit()" method="post"><div>
        <input type="text" id="email" name="email" value="">
        <input class="btn" type=submit value="Submit"></div>
            </form>

Here’s emailSubmit():

    function emailSubmit(){
         $.ajax({
                      type: "POST",
                      url: "mysitesip/addemail.php",
                      data: {
                            email: $("#email").val()
                        },
                      success: function (data) {
                            $('#success').html(data);

                      }
                    });  // end Ajax    
    }

When I click on the submit buton, it posts, with the email address as a parameter, to itself, instead of addemail.php, and the page refreshes? Why is this happening? If I get rid of the method=”post”, then the form puts out a GET request to itself, but with with correct email as a parameter. This is extremely confusing to me, because the .ajax method clearly states that the type is POST. Why would changing the “method” of the form alter the posting for emailSubmit()?

The .ajax call was taken verbatim from an EXTREMELY similar usage on another one of my pages, where it works fine.

(When I say “it is POSTing” or “it is GETing”, I am using firebug to see these things)

  • 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-28T04:22:38+00:00Added an answer on May 28, 2026 at 4:22 am

    You are doing nothing to cancel the standard form submission.

    The net result is that the Ajax stuff submits to the URI you specify, then the form submits as normal (to the URI of the current page because you forgot the action attribute).

    1. Stop using intrinsic event attributes (i.e. the onsubmit attribute)
    2. Use JS event binding instead
    3. prevent the default submit action
    4. Make sure that you have an action attribute pointing at a sensible place so if the JS fails for any reason, the form still works. c.f. Unobtrusive JavaScript.

    Or, as a quick and dirty hack … return false at the end of the onsubmit attribute.

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

Sidebar

Related Questions

I have a form with two text_fields: <input type=text id=post_name name=post[name] /> <input type=text
I have a simple email form: <form method=post action=process-form.php id=emailForm name=emailForm target=_self> <h4>Sign up
<form method=post action=sendmail.php name=Email_form> Message ID <input type=text name=message_id /><br/><br/> Aggressive conduct <input type=radio
I have the following email form: <form action=mailer.php method=post name=form1 id=form1 onsubmit=MM_validateForm('from','','RisEmail','name','','R','verif_box','','R','message','','R');return document.MM_returnValue> <table
I have one form as shown below: Page 1: <form name = form1 method=post
I created this form: <form method=post action=process-form.php id=emailForm name=emailForm target=_self> <h4>Sign up to be
Assume I have a form class SampleClass(forms.Form): name = forms.CharField(max_length=30) age = forms.IntegerField() django_hacker
I have a form with a name and an email address. I want a
I have a simple reg form (Name, Email, Password) on my website and im
I have a several input fields in a form each having a unique name.

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.