//javascript
var queryParams = {
"userId": userId,
"factoryId": factoryId
};
$.ajax({
type: "POST", //默认是GET
url: "/Home/SubmitToProcessed",
data: queryParams,
async: false, //异步
cache: false, //不加载缓存
dataType: "json",
success: function (data) {
//return single entity
if (data.result) {
$("#contentBefore").hide();
$("#contentAfter").show();
}
else {
$.messager.alert("操作失败", data.message);
}
//return entity list
foreach( var item in list)
{
item.id,
item.categoryName,
}
},
error: function (xmlHttpRequest, textStatus, errorThrown) {
$.messager.alert("操作失败", "操作失败");
}
});
//c# action
[HttpPost]
public JsonResult SubmitToProcessed(FormCollection collection)
{
boolean rlt = true //......call function;
return Json(new { result = rlt, message = (rlt == false ? "操作失败":"") }, JsonRequestBehavior.AllowGet);
List<user> userlst = .....
return Json(userlst, JsonRequestBehavior.AllowGet);
}