我试过这样但是无法获得数组列表。它返回'null'
var data=[];
data[0] = '1';
data[1] = '2';
$.ajax({
url: '@Url.Action("AddFrequencyWeekly", "Plannar")',
type: "POST",
data: { data: data },
dataType: 'json',
success: function (data) {
alert("Record Updated Successfully");
}
});
我的模型类代码
public JsonResult AddFrequencyWeekly(string[] data)
{
}
数据值显示为“null”
请帮帮我?
答案 0 :(得分:1)
var datas = { data0: '1',
data1: '2' };
$.ajax({
url: '@Url.Action("AddFrequencyWeekly", "Plannar")',
type: "POST",
data: datas,
dataType: 'json',
success: function (data) {
alert("Record Updated Successfully");
}
});
答案 1 :(得分:0)
它是你期望在action方法中接收数据的方式, 试试
public JsonResult AddFrequencyWeekly(IEnumeable<string> data)
{
}