最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Jquery .post and form data - Stack Overflow

programmeradmin5浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论