admin管理员组

文章数量:1399968

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 mand to send it?

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 mand to send it?

Share Improve this question edited Jul 29, 2009 at 20:47 Matthew Groves 26.2k10 gold badges73 silver badges125 bronze badges asked Jul 29, 2009 at 19:44 Tony BorfTony Borf 4,6709 gold badges45 silver badges52 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 10

use the .serialize method.

var postData = $('#formId').serialize();
$.post(url,  postData);
$("form").submit(function(e) {
    e.preventDefault();
    $.post("/url", $(this).serialize(), callbackFunction);
});

jquery form plugin is what you need.

本文标签: javascriptJquery post and form dataStack Overflow