$.post 传递数组等复杂数据
之前总结了一篇关于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!!!
声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇:没有了
- 下一篇:没有了