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;
}
Using alertify, I have set 10
secs delay for the success message but it is not working? I just need to show success alert to user and then
redirect to same page.
Tried using delay
but not working though:
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'] ?>";
});
How could I set some delay in success message so that user can see it and only then post the form details to controller action ?
.delay() is used only between jQuery effects. Here is what the docs say
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.
So the only way to create a delay before post method is 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);