1
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'] ?>";
            });

ユーザーがそれを見て、フォームの詳細をコントローラーアクションに投稿できるように、成功メッセージに遅延を設定するにはどうすればよいですか?

4

1 に答える 1

1

.delay()は、jQuery エフェクト間でのみ使用されます。ドキュメントの内容は次のとおりです

.delay() メソッドは、キューに入れられた jQuery エフェクト間の遅延に最適です。制限があるため (たとえば、遅延をキャンセルする方法は提供されません)、.delay() は JavaScript のネイティブな setTimeout 関数に代わるものではなく、特定のユース ケースにより適している場合があります。

したがって、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);
于 2015-07-09T11:22:12.957 に答える