2 回答

TA贡献1871条经验 获得超8个赞
我认为有两点需要解决:
没有类型的ajax将成为
GET
请求。放POST
尝试使用数据:
JSON.stringify({ 'pDetail': billArray})
所以,它变成:
$.ajax({
url: "/Cashier/UpdateProductQuantity",
type : 'POST',
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify({ 'pDetail': billArray}),
responseType: "json",
success: function (data) {
alert('success');
}
});

TA贡献1784条经验 获得超9个赞
我会用你的控制器尝试 FromBody:
[HttpPost]
public JsonResult UpdateProductQuantity([FromBody]List<Test> pDetail)
{
return Json("", JsonRequestBehavior.AllowGet);
}
你说你需要发布你的 billArray 所以你的 ajax 请求应该是这样的发布类型:
$.ajax({
url: "/Cashier/UpdateProductQuantity",
type : 'POST', //this is the difference
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify({ 'pDetail': billArray}),
responseType: "json",
success: function (data) {
alert('success');
}
});
- 2 回答
- 0 关注
- 377 浏览
添加回答
举报