我怎么能即兴不继续,直到提交完成并退出



>我正在使用jQuery即兴库,但不了解它的异步性质。 我在下面有一些代码,我想在提示运行后重定向。 如果我的 data.redirectPage 语句为真,我不希望执行下一行代码。

               success: function (data) {
                    if (data.redirectPage == "hackathonregistration") {
                        $.prompt("Your code has been accepted and you will now be redirected to the hackathon registration page",
                        {
                            submit: function() {
                                window.location.href = "/Register/hackathon";
                            }
                        });
                    }

从我快速阅读的有关即兴的内容来看,您的代码看起来不错。
除了缺少关闭success功能的}...;)

并且您尝试触发的提交上没有按钮。
这是一个重要的 AND。

试试这个:

success: function (data) {
    console.log(data.redirectPage);
    if (data.redirectPage == "hackathonregistration") {
        $.prompt("Your code has been accepted and you will now be redirected to the hackathon registration page",
        {
            buttons: { "Yes": true, "No": false },
            submit: function(e,v,m,f) {
                // use e.preventDefault() to prevent closing when needed or return false.
                // e.preventDefault();
                console.log("Value clicked was: "+ v);
                if(v){
                    window.location.href = "/Register/hackathon";
                }
            }
        });
    }
}

我想v波利安是真/假。
就像说的那样,我在Impromtu上读得非常快

就个人而言,我使用SweetAlert。寻找它作为替代方案...可能更容易。

相关内容

最新更新