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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:52:35+00:00 2026-05-19T04:52:35+00:00

I have some problem with my form. i want to use jquery ajax to

  • 0

I have some problem with my form.

i want to use jquery ajax to validate a form against a database and i encounter different problems.

1.

$('#formsubmit').click(function(e) {
    e.preventDefault(); // this is not working, the page reloads
});

2.

$('#formsubmit').live('click', function(e) {
    e.preventDefault(); //works, but...
    var firstname = $('#firstname').val(); // returns an empty string and ...
    firstname = document.getElementById('firstname'); //does not return anything either
    alert("$('#firstname')"); // returns [object][object] ... should'nt it be [object][html inputelement]
});

so far i havent been able to trigger an ajax load on click on the submit button of my form because i cannot get the values of my input fields.

am i missing something here?
Is it possible to use another method for:
1. prevent page reload on submit-click and
2. get all values of the form and send them via ajax to my php script
3. wait for the answer and display it in the according html elements.

  • 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-19T04:52:36+00:00Added an answer on May 19, 2026 at 4:52 am

    The problem is you’re preventing the click event, not the submit event, which is what you want to catch here, like this:

    $("#formid").live("submit", function(e) {
      e.preventDefault();
      $.post("myPage.php", $(this).serialize(), function(result) { 
        $("#resultContainer").html(result);
      });
    });
    

    In the above, we’re using .serialize() on the <form> itself to get all the data to submit (from all successful inputs), just like a normal submission would do (with no JavaScript).


    Also, I ca’t tell from your question, but be sure your id attributes are unique, e.g. there is only one id="firstname", you’ll have many issues if that’s not the case.

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

Sidebar

Related Questions

I have some problems sending an id though jquery. I have a form select
I have a problem with jQuery Validator. I want to use required property on
I seem to have a problem passing some strings on from one form to
I have some problem to get the utf-8 string from PHP using jQuery $.load()
I have some problem. Dialog.dismiss() does not work. I want to input ip, username,
I have some problem with this mongoid. It's my first time to use mongoDB,
I have some problem with Emit mapper when I try to save in database
I am using jquery validation plugin to validate my form. I have one field
I want to have a bound form from an object to use the is_valid
I have an ASP.Net MVC page where I want to use AJAX to update

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.