I have this code
$.ajax({
type: 'POST',
url: 'ajaxfunctions.php',
data: {email: email},
success: function(data)
{
if(data == "true" || data == "false")
{
alert("Response")
}
else
alert("Data: " + data);
}
});
with this PHP-Script
if(isset($_POST['email']))
{
$email = $_POST['email'];
$countEmail = $db->getCountEmail($email);
if($countEmail == 1)
echo "true";
else {
echo "false";
}
}
The problem is, that it never comes in the alert("Response") case. Always in the other. In the alert window I then got my full index.html content.. What am I doing wrong?
@devShuba在Chrome中监控您的Ajax请求,这是之前的相关文章, 在Chrome中监控请求
maybe the isset($_POST['email'])
is returning false, that's why.
can you do a var_dump(isset($_POST['email']));
and check if it evaluates to true? if no, then you have to check if the email is correctly posted using your javascript.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.