So I've been testing and found out that if
session_start();
if ( $_POST['animal'] != $_SESSION['animal'] ) die(json_encode(false));
is run inside my PHP function to handle the AJAX call, then back in JavaScript land where I have
success: function (correctCaptcha) {
console.log("correctCaptcha is " + correctCaptcha); // test
console.log("correctCaptcha's type is " + typeof (correctCaptcha)); // test
if ( correctCaptcha )
{
I'm seeing that correctCaptcha is the string "false" rather than the boolean value false. Consequently, the if block is entered and that's what's causing a bug. How can I get PHP to give me a boolean as the JSON it generates? Or what is a better solution?
if ( correctCaptcha == "false")