1

在我的表单成功时,我调用了一个名为“onReSuccessFunction()”的函数。在该函数中,我有一个表单提交代码。但在完成表单提交之前,下一行代码被执行并重定向到另一个页面。因此第一个功能检查不起作用。有人有解决此问题的想法吗?

代码

@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"; 
        }
    }
}
4

1 回答 1

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"; }
    }
}
于 2013-05-27T11:19:57.997 回答