How to create javascript object from form elements using jQuery
Posted
by ob
on Stack Overflow
See other posts from Stack Overflow
or by ob
Published on 2010-03-24T19:53:02Z
Indexed on
2010/03/24
20:03 UTC
Read the original article
Hit count: 274
I'd like to be able to create a javascript object from my html form and am wondering if there's a good way to do this using jquery. I guess what i'm looking for is something similar to $.serialize, but which would result in a map instead of a string.
<form>
<input type="text" name="foo1" value="bar1" />
<input type="text" name="foo2" value="bar2" />
</form>
desired result:
{ foo1:"bar1", foo2:"bar2" }
© Stack Overflow or respective owner