Skip to content
Advertisement

sweetalert not working in php after form submission

i have a simple php form, on form submit i want to display sweet alert, i did the following code:

JavaScript

howerver sweetalert doesnt show up after formsubmit, can anyone please tell me what is wrong in here, thanks in advance

Advertisement

Answer

Because your body is empty and sweetalert append your code to empty body & you got error in your console like this:

console error

If you want to send alert with this method, you should have something in your body.

For example I echo simple span on my code and it’s work for me:

JavaScript

Or you can use AJAX if you use jQuery Instead of alert like this:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement