-3
如何将带有列表数据的'things'发送到控制器方法?除Bins Data外,我正在获取所有数据? Bins显示为空,计数为0.将列表从另一个列表从jquery传递到mvc中的控制器
即使我尝试了对bin和数据值进行了字符串处理,但没有奏效。
$(document).ready(function() {
var bins=[{'binName':testbiname,'isSelected':true}]
var things = [
{ id: 1, color: 'yellow',Bins:bins },
];
things = JSON.stringify({ 'things': things });
$.ajax({
contentType: 'application/json; charset=utf-8',
dataType: 'json',
type: 'POST',
url: '/Home/PassThings',
data: things,
success: function() {
$('#result').html('"PassThings()" successfully called.');
},
failure: function (response) {
$('#result').html(response);
}
});
});
public void PassThings(List<Thing> things)
{
var t = things;
}
public class Thing
{
public int Id { get; set; }
public string Color { get; set; }
*public list<BinSelecter> Bins{get;set;}*
}
public class BinSelecter
{
public string binName {get;set;}
public bool isSelected {get;set;}
}
你的JavaScript事情并不包含任何垃圾箱对象 – Rick
你可以展示BinSelecter的模型? – Usman