我正在使用内置的 ASP.NET AjaxHelper,如下所示:
@using (Ajax.BeginForm("Endpoint", "MyController", null, new AjaxOptions()
{
HttpMethod = "post",
OnComplete = "onSubmitSuccess",
}))
{
<input type="text" name="a lot of input fields here" />
<button type="submit">Submit</button>
}
我已经创建了 onSubmitSuccess() 函数,并在 ajax 请求成功时触发。
我的问题:是否可以挂钩触发 post 请求的实际 javascript 函数?
在允许它发布 ajax 请求之前,我需要进行自定义表单验证检查。