PHP AJAX总是返回相同的结果

So I'm trying to check if the email is already in use (for a password reset). So I have my JS

//Check if email exists
$(document).ready(function() {
//listens for typing on the desired field
$("#email").keyup(function() {
    //gets the value of the field
    var email = $("#email").val(); 

    //here is where you send the desired data to the PHP file using ajax
    $.post("../classes/check.php", {email:email},
        function(result) {
            if(result == 1) {
                //Email available
                console.log("Good");
            }
            else {
                //the email is not available
                console.log("Bad");
            }
        });
});
});

And then my PHP

<?php
//Include DB
include_once '../db.php';

if(isset($_POST['email'])){
    //Get data
    $email = htmlspecialchars($_POST['email'], ENT_QUOTES, 'UTF-8');
}
else{
    header('Location: /');
}
//Send requst to DB
$stmt = $con->prepare("SELECT * FROM users WHERE email = :email");
$stmt->bindValue(':email', $email, PDO::PARAM_STR);
$stmt->execute();

if($stmt->rowCount() > 0){
    //Email found
    echo 1;
}
else{
    //Email not found
    echo 0;
}

So I start off by making sure there's a recording in my DB. Which there is, so I enter it. Now I go over to the console and all I get is Bad, which means that the email is not found, but it's in the database. So I'd assume all it returns is 0. Any ideas? Could it be an error in my code?

The PDO documentation warns that rowCount might not work with all drivers. A more reliable and efficient way to do it is:

$stmt = $con->prepare("SELECT COUNT(*) as count FROM users WHERE email = :email");
$stmt->bindValue(':email', $email, PDO::PARAM_STR);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if ($row['count'] > 0) {
    echo 1;
} else {
    echo 0;
}

Another thing to try:

$email = trim($_POST['email']);

because sometimes there's extra whitespace in theinput field.