我在应用程序中使用简单的jQuery$.post时遇到了问题.我在网上try 了许多方法和解决方案,但都没有效果.发送POST请求时,我看到400错误
public class RecoveryAdhocInvoicingModel : PageModel
{
Public IActionResult OnPostDoJob(string invNo, string account)
{
//var emailAddress = Request.Form["emailaddress"];
// do something with emailAddress
return new JsonResult("");
}
}
在我的脚本中,通过单击按钮调用$.post方法:
$('#submitBtnUpdateJob').click(function (evt) {
var formdata = new FormData();
formdata.append("invNo", $('#adhocInvoiceNumber').val());
formdata.append("account", $('#invoiceAccountInput').val());
$.post(window.location.href + '?handler=DoJob', JSON.stringify(formdata), function () {
alert('Posted');
});
});