I want to execute a SweetAlert that is inside an echo in php, but I get that the variable "swal" is not defined.
echo '<script>
swal({
title: "",
text: "Su solicitud se ha registrado correctamente " + solicitud,
icon: "success",
value: "confirm",
buttons: {
confirm: "Confirmar"
}
})
</script>';
I am calling the library script at the end of my document.
The problem is because of the way you are printing your variable of type script
If you notice, I have changed this line
text: "Su solicitud se ha registrado correctamente "'." + solicitud ".',
by placing single quotes so that it receives the request variable correctly.I enclose an HMTL snippet (not php) where I place the library at the beginning since it doesn't read it at the end: