Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
96
rated 0 times [  98] [ 2]  / answers: 1 / hits: 34594  / 15 Years ago, tue, august 4, 2009, 12:00:00

I would like to use jQuery.ajax to submit a form using POST without having to specify everything manually in the data: part.



This is what I don't want:



data:   username= + document.getElementById(username).value + 
&email= + document.getElementById(email).value,


Is there a way to just have it include alla elements with their values from an entire FORM field? This form is generated dynamically so it would save me a lot of time!


More From » jquery

 Answers
11

Use serialize method.



data :   $(form).serialize()

[#98992] Friday, July 31, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ryderalfonsos

Total Points: 655
Total Questions: 88
Total Answers: 91

Location: Nauru
Member since Thu, Feb 2, 2023
1 Year ago
;