I am able to display sweet alert after the page refresh but I have to click on Ok button which I am getting on sweet alert to redirect the page.Please help me in this.
JavaScript
x
8
1
<?php
2
echo '<script type="text/javascript">';
3
echo 'setTimeout(function () { swal("WOW!","Message!","success");';
4
echo '}, 1000);'
5
echo 'window.location.href = "index.php";';
6
echo '</script>';
7
?>
8
Advertisement
Answer
To specify a callback function, you have to use an object as the first argument, and the callback function as the second argument.
JavaScript
1
12
12
1
echo '<script>
2
setTimeout(function() {
3
swal({
4
title: "Wow!",
5
text: "Message!",
6
type: "success"
7
}, function() {
8
window.location = "redirectURL";
9
});
10
}, 1000);
11
</script>';
12