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 isn'.$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 isn'.$Dep.'/'.$fy.'/ "+"'.$id.'.nKindly submit the original copy of this letter to CRDS.")';
echo '</script>';
echo "<script>window.location.href='dashboard.php'</script>";
exit;
3
Answers
most likely the swal function is wrong, look at the swal documentation and here is an example of how to use it, maybe you are missing the fire.
that on that side of the alert, however if we look at the topic more in depth, in the last line you are changing the url with the window.location.href, then it would be good to comment or implement it differently because there you are redirecting it to another page and the alert will not be displayed.
using SweetAlert you can just simply use the:
echo 'swal("Some'.$variable.'text!", "You clicked the button!", "success")';
but in
SweetAlert2
you can just simply use:In your headings,
Add,
Then,