在MVC中使用Jquery发布WebGrid中选定的模型

在MVC中使用Jquery发布WebGrid中选定的模型,jquery,asp.net-mvc-4,controller,viewmodel,jquery-post,Jquery,Asp.net Mvc 4,Controller,Viewmodel,Jquery Post,在MVC中,我有一个WebGrid。此WebGrid使用名为PaginatedList的ViewModel填充。确实具有实际的ViewModel集合,即RequestViewModel集合 在特定事件中,我希望使用Jquery Post将所选的ViewModel(即RequestViewModel)发送给Controller。我不喜欢使用$(“form”).Serialize()发送整个集合 请帮忙。谢谢你抽出时间 编辑: 在控制器中: var accessRequestViewModel=ob

在MVC中,我有一个WebGrid。此WebGrid使用名为PaginatedList的ViewModel填充。确实具有实际的ViewModel集合,即RequestViewModel集合

在特定事件中,我希望使用Jquery Post将所选的ViewModel(即RequestViewModel)发送给Controller。我不喜欢使用$(“form”).Serialize()发送整个集合

请帮忙。谢谢你抽出时间

编辑: 在控制器中:

var accessRequestViewModel=objAccessRequest.FetchAll();
var paginatedUAReqs=new PaginatedList<AccessRequestsViewModel>(accessRequestViewModel);
return view(paginatedUAReqs);
@model PaginatedList<RequestsViewModel>
var accessReqWebGrid= new WebGrid(model);
WebGrid.Column("ID");
WebGrid.Column("Name");
WebGrid.Column("Action");// This column has a drop down. On change of selection, jquery post has to be done. Sending the selected row as a model to controller.
尝试过的事情:

var accessRequestViewModel=objAccessRequest.FetchAll();
var paginatedUAReqs=new PaginatedList<AccessRequestsViewModel>(accessRequestViewModel);
return view(paginatedUAReqs);
@model PaginatedList<RequestsViewModel>
var accessReqWebGrid= new WebGrid(model);
WebGrid.Column("ID");
WebGrid.Column("Name");
WebGrid.Column("Action");// This column has a drop down. On change of selection, jquery post has to be done. Sending the selected row as a model to controller.
在Javascript中:

在控制器中:

正在命中断点,但viewmodel中的值不是我发送的值。

使用了以下命令

$.ajax({
                                url: commentsWinPath,
                                type: 'POST',
                                dataType: 'json',
                                contentType: 'application/json',
                                data: JSON.stringify(data),
                                success: function (data) {
                                    //...
                                },
                                error: function (jqXHR, textStatus, errorThrown) {
                                    //...
                                }
                            });

$.post对我不起作用,内容类型在解决该问题中起了主要作用。

您必须提供一些代码示例,并请说明您已经尝试过的内容。
$.ajax({
                                url: commentsWinPath,
                                type: 'POST',
                                dataType: 'json',
                                contentType: 'application/json',
                                data: JSON.stringify(data),
                                success: function (data) {
                                    //...
                                },
                                error: function (jqXHR, textStatus, errorThrown) {
                                    //...
                                }
                            });