从onclick方法调用控制器中的动作

use*_*610 1 asp.net-mvc asp.net-mvc-3

我有一个像这样的CheckBox

<td><%= Html.CheckBox("seleccionado", false, new { onclick = "SeleccionarItems();" })%></td>
Run Code Online (Sandbox Code Playgroud)

现在,我想从我的控制器调用一个特定的动作,并传递checkBox的值我该怎么做...

   function SeleccionarItems() {
           -- call method to controller and pass value
       }
Run Code Online (Sandbox Code Playgroud)

xbr*_*ady 5

我会使用jQuery发布到控制器:

http://api.jquery.com/jQuery.ajax/

$.ajax({
    type: 'POST',
    url: controllerName + '/ActionName',
    data: { 'checkValue': $('#seleccionado').val() },
    dataType: 'json',
    success: function (jsonData) {
        //This function gets called after posting to the server
    },
    error: function () {
        alert('Error!');
    }
});
Run Code Online (Sandbox Code Playgroud)

这是一个解释整个过程的教程:链接