views:

697

answers:

2

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
+4  A: 

Serialize does include all enabled input elements with a name attribute.

Josh Stodola
why do jquery use name attribute to serialize a form, instead of using id attribute?
frabiacca
@frabiacca Because the `name` attribute is the identifier for POST data http://www.w3schools.com/tags/att_input_name.asp
Josh Stodola
thx josh, even for the link ;)
frabiacca
thanks ! this was really helpful !
Preets