Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

serialize doesn't include hidden fields

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?

like image 690
gruszczy Avatar asked Aug 14 '09 13:08

gruszczy


2 Answers

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

like image 105
Josh Stodola Avatar answered Nov 19 '22 16:11

Josh Stodola


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.

like image 42
Jim Schubert Avatar answered Nov 19 '22 15:11

Jim Schubert