Alert works and sweetalert not [closed]

1

I'm trying to use sweetalert to give a "Submitted" alert.

if($rstSql["cod_erro"] == 0)
{
    echo '<script> swal("Good job!", "You clicked the button!", "success"); <script>';
}
else
{
   echo '<script>alert("message2");</script>';   
}

Apparently, the default alert works while SWAL does not. I tested it on another page and called it normally, the libraries are being called in:

<script src="swap/sweet-alert.js"></script> 
<link rel="stylesheet" type="text/css" href="swap/sweet-alert.css">

When I use debug in chrome I get the following message:

  

Uncaught TypeError: Can not read property "prototype'of undefined>

    
asked by anonymous 22.09.2015 / 19:51

1 answer

2

Good afternoon! I logged into the SweetAlert website ( link ), opened the browser console and typed the same line you commented up there, or either:

swal("Good job!", "You clicked the button!", "success");

I did this to find out if it was not some parameter error you had or something, but it worked correctly! So apparently the SweetAlert JavaScript is ok!

I re-read your post, and I noticed that you give an echo, however you are not closing the <script> tag.

Please try to replace this line:

echo '<script> swal("Good job!", "You clicked the button!", "success"); <script>';

For this:

echo '<script> swal("Good job!", "You clicked the button!", "success"); </script>';

And please, give us the answer if it worked.

    
22.09.2015 / 21:07