暂停页面执行,直到jQuery警报关闭后,再运行函数

Pause page execution until after jQuery alert is closed, then run function

本文关键字:函数 再运行 jQuery 执行 直到 暂停      更新时间:2023-09-26

我有一个jQuery $.alert.fadeOut(1000)连续工作,但我不喜欢我所看到的结果。我希望在用户关闭$.alert之后只运行.fadeOut(1000)。我知道您实际上无法捕获警报的关闭事件,但是有人可以建议一个可能实现我正在寻找的工作方法吗?

这是现有的ajax调用,我试图实现的变化:

$.ajax({
url: sURL + "utility/mymethod",
type: "POST",
data: {ClientNum: ClientNum},
dataType: 'json',
success: function(json) {       
if (typeof(json.ClientEmail) != "undefined" && json.ClientEmail !== null && json.ClientEmail !== "") {
    $.confirm("Please call . . . .",                
    function(){ 
        if (json.ClientEmail){
            send_email(json);
        }
    },              
    function(){
        $.msg("Password recovery information has NOT been sent.",
        {header:'Password Not Sent', live:10000});
        $('#ajaxShield').fadeOut(1000);
    })
} else {
    //THIS IS WHERE I WANT THE FADEOUT TO WAIT FOR THE ALERT
    $.alert("There is no email address.")
    $('#ajaxShield').fadeOut(1000);
}; 
}, 
error:function (xhr, ajaxOptions, thrownError){ alert('Problem, Status code:'+xhr.status+', Error:'+thrownError);} 
});

我希望我的覆盖保持可见,直到用户确认警报消息。

谢谢。

$。alert不是原生的JQuery,所以可能是一个异步操作的插件。但谷歌搜索表明,它并不是一个比较出名的。

简单的测试……

改变
$.alert("msg")

alert("msg")

这看起来像你想要的吗(警报同步工作)。

如果这更像是你所追求的,下一阶段是确定你的插件是如何工作的(如果你想继续使用它)