Javascript Ajax:将模型列表传递给控制器
我有一个视图,它将一个模型列表作为模型Javascript Ajax:将模型列表传递给控制器,javascript,ajax,model-view-controller,model,Javascript,Ajax,Model View Controller,Model,我有一个视图,它将一个模型列表作为模型 @model List<Collections.Models.Status> 在调试器中转换为: $.ajax({ url: "/Home/Update", data: JSON.stringify(System.Collections.Generic.List`1[Collections.Models.CollectionStatus]), type: 'POST', dat
@model List<Collections.Models.Status>
在调试器中转换为:
$.ajax({
url: "/Home/Update",
data: JSON.stringify(System.Collections.Generic.List`1[Collections.Models.CollectionStatus]),
type: 'POST',
dataType: 'json',
success: function (responseJSON) {
if (responseJSON.message == 'success') {
alert('here');
}
},
error: function (error) {
showModal("Error: " + error.message);
}
});
如何传递列表的实际值而不是System.Collections.Generic.list[Collections.Models.Status]
我尝试过@Model.ToList(),@Html.Raw(Model),但都没有成功。将contentType属性设置为application/json。 并使用下面的代码设置数据属性
data: JSON.stringify({'your controllers parameter name': '@Model'})
它执行了调用,但没有传递值,当我检查传入的参数时,控制器中的计数为0。
data: JSON.stringify({'your controllers parameter name': '@Model'})