I have an AJAX request which is working, but want to have, depending on the PHP file's echo, another statement in my success box.
Here's my code how it is right now:
jQuery success function:
success : function(data) {
if (data == 'ERROR') {
$.smallBox({
title: "Thank you!",
content: "<p> ERROR </p>",
color: "#296191",
timeout: 10000,
icon: "fa fa-bell swing animated"
});
}
else {
$.smallBox({
title: "Thank you!",
content: "<p> NOPE </p>",
color: "#296191",
timeout: 10000,
icon: "fa fa-bell swing animated"
});
}
}
The part which comes back from PHP:
if ($bla = $foo)
{
echo 'ERROR';
}
The if-statement always jumps to the small box that says NOPE (the second one), no matter if data is 'ERROR' or not.
I tried different things such as:
In PHP script:
echo 1;
and jQuery:
if (data == 1) { //...
...or instead of echo, I tried exit in PHP, but nothing seems to work right / the if is never true.
I'm quite sure I need to do something else with the PHP part, but what is it?
Can somebody push me in the right direction, please? Thank you!