Alertify - 延迟显示成功消息

Alertify - Show success message with delay

if(jQuery("#form_fill_hours").validationEngine('validate')){

    alertify.confirm("Are you sure you want to submit this exam form to your teacher?", function (e) {
    if (e) {
        alertify.set({ delay: 10000 });
        alertify.success("Your exam form has been submitted");
        $.blockUI.defaults.message = "<h1 class='block_msg'>Please Wait...</h1>";
        $.post( SITE_URL+"fill/save/saveformexam?type=1",$("#form_fill_hours").serialize(), function( data ) {
            window.location.href="<?php echo EXAM_URL."exam/weekly/index?week=".$_GET['week'] ?>";
        });
    } else {
        alertify.error("Your exam form is not submitted");
    }
});
            return false;
    }else{
            return false;
    }

使用 alertify,我为成功消息设置了 10 秒延迟,但它不起作用?我只需要向用户显示成功警报,然后 重定向到同一页面。

已尝试使用 delay 但无法正常工作:

alertify.success("Your exam form has been submitted");//show alert to user
delay(100);//wait for 10 secs and then post form data
$.post( SITE_URL+"fill/save/saveformexam?type=1",$("#form_fill_hours").serialize(), function( data ) {
                window.location.href="<?php echo EXAM_URL."exam/weekly/index?week=".$_GET['week'] ?>";
            });

我如何在成功消息中设置一些延迟,以便用户可以看到它,然后才 post 控制器操作的表单详细信息?

.delay() 仅在 jQuery 效果之间使用。这是文档所说的

The .delay() method is best for delaying between queued jQuery effects. Because it is limited—it doesn't, for example, offer a way to cancel the delay—.delay() is not a replacement for JavaScript's native setTimeout function, which may be more appropriate for certain use cases.

所以在 post 方法之前创建延迟的唯一方法是 settimeout

setTimeout(function(){
  $.post( SITE_URL+"fill/save/saveformexam?type=1",$("#form_fill_hours").serialize(), function( data ) {
    window.location.href="<?php echo EXAM_URL."exam/weekly/index?week=".$_GET['week'] ?>";
  });
}, 1000);