之前总结了一篇关于ajax使用
function CreateTask() {
var rows = $('#itemGrid').datagrid('getSelections');
if (rows) {
var ids = [];
$.each(rows, function (index, value) {
ids.push({ name:'ids',value:value.Id });
})
ids.push({ name: 'taskname', value: $('#taskname').val() });
var selected = $('#userTree').tree('getSelected');
if (selected) {
ids.push({ name: 'recieverid', value: selected.attributes.UserId });
ids.push({name:'recievername',value:selected.text});
}
$.post("/Inspection/CreateTask", ids, function (data) {
$.messager.alert(data.title,data.msg);
}, 'json')
}
}
后台代码
public ActionResult CreateTask(List<int> ids,string taskname,int recieverid,string recievername)
{
}
主要思路是网数组中添加键值对对象,name属性的值需要与后台controller接收的数据字段同名
GOOD LUCK!!!