How can I get form data with JavaScript jQuery

0 votes

Is there a simple, one-line way to get the data of a form as it would be if it was to be submitted in the classic HTML-only way?

For example:

<form>
    <input type="radio" name="foo" value="1" checked="checked" />
    <input type="radio" name="foo" value="0" />
    <input name="bar" value="xxx" />
    <select name="this">
        <option value="hi" selected="selected">Hi</option>
        <option value="ho">Ho</option>
</form>

Output:

{
    "foo": "1",
    "bar": "xxx",
    "this": "hi"
}

Something like this is too simple, since it does not (correctly) include textareas, selects, radio buttons and checkboxes:

$("#form input").each(function () {
    data[theFieldName] = theFieldValue;
});

Jun 29 in Web Development by gaurav
• 17,580 points
22 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Web Development

0 votes
0 answers

How an I get all form elements (input, textarea & select) with jQuery?

Is there an easy way (without listing ...READ MORE

Jul 26 in Web Development by gaurav
• 17,580 points
11 views
0 votes
0 answers

How can I specify Google map with driving direction in jQuery mobile

I have done a Google Maps based ...READ MORE

Jul 20 in Web Development by gaurav
• 17,580 points
12 views
0 votes
0 answers

How Can I create A 5 second Countdown timer with jquery that ends with a login popup?

How would i create a jquery timer ...READ MORE

Jul 28 in Web Development by gaurav
• 17,580 points
8 views
0 votes
0 answers
0 votes
1 answer

How can I create a simple page vertical scroll bar without using jQuery?

Surprisingly, there is not a great, simple ...READ MORE

answered Jun 22 in Web Development by rajatha
• 7,040 points
21 views
0 votes
0 answers

Can regular JavaScript be mixed with jQuery?

For example, can I take this script ...READ MORE

Jun 29 in Web Development by gaurav
• 17,580 points
14 views
0 votes
1 answer

jQuery AJAX submit form

There is a simple input mentioned below ...READ MORE

answered Feb 8 in Java by Soham
• 8,740 points
254 views
0 votes
0 answers

How to reset a form using jQuery with .reset() method

My code : <div id="labels"> <table class="config"> ...READ MORE

May 24 in Java-Script by Kichu
• 19,040 points
63 views
0 votes
1 answer

How to reset a form using jQuery with .reset() method

<input type="reset"> Syntax for reset(): formObject.reset() Syntax to convert ...READ MORE

answered Jun 16 in JQuery by rajatha
• 7,040 points
95 views
0 votes
0 answers
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP