I want to use jQuery-confirm dialog instead of echoing a Javascript alert
from PHP. When I run following code it shows me this error:
$ is not defined
echo "<script>$.alert({title: 'Alert!',content: 'Simple alert!',});</script>";
I want to use jQuery-confirm dialog instead of echoing a Javascript alert
from PHP. When I run following code it shows me this error:
$ is not defined
echo "<script>$.alert({title: 'Alert!',content: 'Simple alert!',});</script>";
Be sure to include the jQuery library first.
Then, if it still do not work, like you say in comments, try wrapping your alert inside a $(document).ready()
:
echo "<script>$(document).ready(function(){$.alert({title: 'Alert!',content: 'Simple alert!'});});</script>";