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

  • Home
  • SEARCH
  • 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 8219043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:01:03+00:00 2026-06-07T13:01:03+00:00

For some reason this code works: $(document).ready(function () { var name = document.getElementById(‘Name’).value; var

  • 0

For some reason this code works:

$(document).ready(function () {
    var name = document.getElementById('Name').value;
    var email = document.getElementById('Email').value;
    var type = document.getElementById('Type').value;
    var message = document.getElementById('Message').value;
    $.post("send.php", {
        Name: "Matt",
        Email: "xxxxxx@hotmail.com",
        Type: "1",
        Message: "GO"
    },

    function (e) {
        alert(e);
    });
});

But this code does not:

$(document).ready(function () {
    $('#btn').click(function () {
        var name = document.getElementById('Name').value;
        var email = document.getElementById('Email').value;
        var type = document.getElementById('Type').value;
        var message = document.getElementById('Message').value;
        $.post("send.php", {
            Name: "Matt",
            Email: "xxxxxx.wsu@hotmail.com",
            Type: "1",
            Message: "GO"
        },

        function (e) {
            alert(e);
        });
    });
});

Also, I have checked my #btn and the id is correct so its not that. The first code returns successful and the email send. The second one does nothing and I cannot debug it well because the response from the server does not show up in my Chrome Developer Tools Network viewer.

Here is the html form:

<form id="form" action="" method="POST">
                <label for="Name">Name: </label>
                <input type="text" name="Name" id="Name">

                <label for="Email">Email: </label>
                <input type="text" name="Email" id="Email">

                <label for="Type">Type: </label>
                <select name="Type" id="Type">
                    <option value="0">General</option>
                    <option value="1">I need a consultation</option>
                    <option value="2">I need a website</option>
                </select>

                <label for="Message">Message: </label>
                <textarea rows="10" cols="50" name="Message" id="Message"></textarea>
                <br />
                <button id="btn" class="submitBtn">Send</button>
    </form>
  • 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-07T13:01:05+00:00Added an answer on June 7, 2026 at 1:01 pm

    Specify the type for the <button> as button.

    <button type="button" id="btn" class="submitBtn" >Send</button>
    

    Working example: http://jsfiddle.net/kXeY8/

    Some browsers interpret the default type for a <button> in a form with no type attribute specified as submit, causing your form to submit instead, preventing the click event’s ajax request from finishing.

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

Sidebar

Related Questions

I have this code, loading XML documents on mouseenter, which works in Firefox: $(document).ready(function()
My code looks something like: $(document).ready(function(){ var cont = 0; function func1(cont) { //Some
I am having problems with the following code $(document).ready(function() { var $selection = $('<div
This is my jQuery code: $(document).ready(function() { $(.bottommrg).mouseenter(function() { $(.bottommrg).animate({ marginTop: '-20px' }, {
for some reason this code wont work, it doesn't seem to read the javascript.php
For some reason this line of code is giving me quite a problem. struct
For some reason, this code does not actually draw my bitmap file... or show
For some reason my code here (this is the entire thing) doesnt actually render
For some reason, this line of code is returning undefined for $(this).attr(href) $(a).attr(href, javascript:page('
I thought this could be achieved with the .prev() function but for some reason

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.