I am trying to display an alert message after the record is inserted in the datbase and normal js alert is working fine the code for this is
echo '<script>';
echo 'alert(" Your request has been successfully filled and your Letter No is\n'.$Dep.'/'.$fy.'/ "+"'.$id.'.\nKindly submit the original copy of this letter to CRDS.")';
echo '</script>';
echo "<script>window.location.href='dashboard.php'</script>";
exit;
But when I am using sweet alert function instead of normal js function it does not display any message.What is wrong in my code> I have included sweet alert library in my code.My code is
echo '<script>';
echo 'swal(" Your request has been successfully filled and your Letter No is\n'.$Dep.'/'.$fy.'/ "+"'.$id.'.\nKindly submit the original copy of this letter to CRDS.")';
echo '</script>';
echo "<script>window.location.href='dashboard.php'</script>";
exit;
In your headings,
Add,
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
Then,
echo '
<script type="text/javascript">
$(document).ready(function(){
swal({
title: "Successfully save!",
html: "Your request has been successfully filled...",
timer: 2000,
timerProgressBar: true,
}).then(function() {
window.location = "( Your link here. )";
});
});
</script>
';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With