如何将jQuery列表发送到MVC控制器 [英] How to send jquery list to mvc controller

查看:85
本文介绍了如何将jQuery列表发送到MVC控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对MVC完全陌生.我必须执行以下操作:

I`m completely new to MVC. I have to do the following:

我有4个列表a,b,c,d,这些列表根据单击的添加或删除按钮动态填充.单击提交按钮时,我需要将列表的值发送到控制器.我怎样才能做到这一点?请给我一个示例,并在链接中提供一个示例.

I have 4 lists a, b, c, d that are filled dynamically, based on add or delete button clicked. I need to send the values of the list to the controller when submit button is clicked. How can I do that? Please give me an example ot a link where I will have an example.

推荐答案

这是用于序列化列表的便捷插件.然后,您可以像这样对数据进行序列化:$('#a').serializelist()并将其传递给后端,并根据需要对其进行处理.

Here's a handy plugin for serializing lists. Then you can serialize the data like so: $('#a').serializelist() and pass that to your back end and treat it however you'd like.

http://github.com/botskonet/jquery.serialize-list

更具体地说...

$('.submit').click(function() {
  $.ajax({
    type: "POST",
    url: "process.php",
    data: $('#a').serializelist(),
    success: function(){
     alert( "Success!");
    }
  });
});

这篇关于如何将jQuery列表发送到MVC控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆