2 回答
TA贡献1865条经验 获得超7个赞
试试这个解决方案:
JS:
var payload = new FormData();
payload.append('TestTitle', $('#TestTitle').text());
payload.append('TestId', $('#TestId').val());
payload.append('TestGuid', $('#TestGuid').val());
var xhr = new XMLHttpRequest();
xhr.addEventListener('readystatechange', onStateChange);
xhr.open('POST', '/test/savetest?rand=' + Math.random(),false);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(payload);
------
C#:
[HttpPost]
public ActionResult SaveTest(TestViewModel model)
{
if (ModelState.IsValid)
{
//do stuff
}
return new JsonResult() { Data = new { Success = false }, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
}
- 2 回答
- 0 关注
- 147 浏览
添加回答
举报