I run serialize on a form, where on of the fields is hidden - and it's a very important field, which should be posted. Is there any way to easily serialize it through jQuery or should I write my own function?
+2
A:
Maybe combining the two in a single selector would work?
$(":input,:hidden").serialize();
edit: I just tried the above and it worked. but, $("form").serialize(); should automatically take all inputs as others have mentioned.
Jim Schubert
2009-08-14 14:48:26
+4
A:
Serialize does include all enabled input
elements with a name
attribute.
Josh Stodola
2009-08-14 14:48:32
why do jquery use name attribute to serialize a form, instead of using id attribute?
frabiacca
2010-06-30 16:07:34
@frabiacca Because the `name` attribute is the identifier for POST data http://www.w3schools.com/tags/att_input_name.asp
Josh Stodola
2010-06-30 18:34:05
thx josh, even for the link ;)
frabiacca
2010-07-01 10:22:26
thanks ! this was really helpful !
Preets
2010-10-25 18:46:05