Asp.net mvc 如何在带有复选框列表的表单中进行ajax回发

Asp.net mvc 如何在带有复选框列表的表单中进行ajax回发,asp.net-mvc,asp.net-mvc-3,jquery,Asp.net Mvc,Asp.net Mvc 3,Jquery,我在表单中动态绘制复选框: @using (Html.BeginForm("Action", "Controller", FormMethod.Post, new { id="itemsList"})) { foreach (var lt in Model.MyList) { <li> <label id="label"

我在表单中动态绘制复选框:

@using (Html.BeginForm("Action", "Controller", FormMethod.Post, new { id="itemsList"}))
{
foreach (var lt in Model.MyList)
            {                
                <li>                
                    <label id="label">
                        <input value="@lt.itemId" type="checkbox" />
                        @lt.Title</label>
                </li>                        
            } 
}

但我的行动没有被解雇。我做错什么了吗?我希望当我选中复选框时,makeserver call。

ajaxForm
将截取提交并通过ajax发送。但是您需要触发一个submit,以便ajax调用生效

尝试添加:

$('input[@type="checkbox"]').click(function(){ $('#itemsList').submit(); }
您可能希望将复选框选择器细化为更具体的内容

我希望当我选中复选框进行服务器调用时

除非您已经为复选框更改编写了处理程序,否则不应该期望出现这种情况

$(document).ready(function () {
        $('#itemsList').ajaxForm({
            success: Saved,
            error: HandleError
        });

        $(':checkbox').change(function(){
            $('#itemsList').submit();
        });
});
$(document).ready(function () {
        $('#itemsList').ajaxForm({
            success: Saved,
            error: HandleError
        });

        $(':checkbox').change(function(){
            $('#itemsList').submit();
        });
});