在我的表单成功时,我调用了一个名为“onReSuccessFunction()”的函数。在该函数中我有一个表单提交代码。但在完成表单提交之前,下一行代码被执行并重定向到另一个页面.Hence the第一次检查的功能不起作用。有人有想法解决这个问题吗?
代码
@using (@Ajax.BeginForm("ActionEvent", "Energy", new AjaxOptions { OnSuccess = "onReSuccessFunction", HttpMethod = "post",async ="false"}, new { id = "frmEnergy", enctype = "multipart/form-data", target = "ifrReFileUpload" }))
{
@Html.Partial("../Energy/_CreateOrEdit", Model)
}
function onReSuccessFunction(result) {
if (chekHaveAnyFileUpload("#divReUploadDocument")) {
document.getElementById("frmEnergy").submit();
}
if (result.Energy.TransStatus == "2") {
if (moveToNextTab(1) == false) {
window.location.href = "../../folio/Index";
}
}
}
答案 0 :(得分:0)
如果您想在提交代码后结束您的功能,只需使用return;
或使用else if
function onReSuccessFunction(result) {
if (chekHaveAnyFileUpload("#divReUploadDocument")) {
document.getElementById("frmEnergy").submit();
}
else if (result.Energy.TransStatus == "2") {
if (moveToNextTab(1) == false) { window.location.href = "../../folio/Index"; }
}
}