views:

126

answers:

3

I am using .post to post my data to my controller. I would like to pass all the data that I have in a form. Is there an easy way to take all the form data and add it to the .post command to send it?

+5  A: 

use the .serialize method.

var postData = $('#formId').serialize();
$.post(url,  postData);
redsquare
+1  A: 
$("form").submit(function(e) {
    e.preventDefault();
    $.post("/url", $(this).serialize(), callbackFunction);
});
John Sheehan
A: 

jquery form plugin is what you need.

serg