控制器里的方法叫EditTbMenuInfo,调用成功后,执行return Content("ok");返回调用OnSuccess。
但是实际上,没有调用OnSuccess,而是跳转到另外一个页面https://localhost:44342/TbMenu/EditTbMenuInfo,见下图

控制器里的方法叫EditTbMenuInfo,调用成功后,执行return Content("ok");返回调用OnSuccess。
但是实际上,没有调用OnSuccess,而是跳转到另外一个页面https://localhost:44342/TbMenu/EditTbMenuInfo,见下图

你的js脚本有问题,看下控制台是不是报错了,导致直接跳转到EditTbMenuInfo去了。或者用的表单提交,没有阻止表单提交导致直接跑action去了。有帮助麻烦点个采纳【本回答右上角】,谢谢~~有其他问题可以继续交流~
.Net mvc ajax要结合客户端类库,jquery,jquery.validate.min.js,jquery.validate.unobtrusive.min.js,jquery.unobtrusive-ajax.min.js这4个类库都需要导入。
jquery是必须要导入的,而且在第一位置导入
jquery.validate.min.js,jquery.validate.unobtrusive.min.js是验证数据有效性的,根据System.ComponentModel.DataAnnotations定义的进行验证,如果不需要验证数据这2个库可以不导入,导入的话顺序要对,先jquery.validate.min.js再到jquery.validate.unobtrusive.min.js,要不出错也会无法验证
jquery.unobtrusive-ajax.min.js,这个是ajax操作要用到的,用到ajax功能要导入
顺序反了
我这里测试没有问题的,你的类库应该没导入正确,jquery也要导入,而且顺序不能反了。

test.cshtml
@{
Layout = null;
}
<div id="editDiv">
@using (Ajax.BeginForm("Test", "Home", new { }, new AjaxOptions() { HttpMethod = "post", OnSuccess = "afterEdit",OnFailure= "OnFailure" }, new { id = "editForm" }))
{
<input type="hidden" name="CreateTime" id="txtCreateTime" />
<input type="hidden" name="CreateBy" id="txtCreateBy" />
<table>
<tr><td>序号</td><td><input type="text" name="Id" id="txtId" /></td></tr>
<tr><td>编号</td><td><input type="text" name="Code" id="txtCode" /></td></tr>
<tr><td>姓名</td><td><input type="text" name="Name" id="txtName" /></td></tr>
<tr><td>链接地址</td><td><input type="text" name="LinkAddress" id="txtLinkAddress" /></td></tr>
</table>
<input type="submit" />
}
</div>
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>
<script>
function afterEdit() { console.log(arguments) }
function OnFailure() { console.log('error',arguments) }
</script>
public ActionResult test()
{
return View();
}
[HttpPost]
public ActionResult test(string id,string code)
{
return Content(DateTime.Now.ToString());
}