0

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
  • 91
  • 3
  • 10

2 Answers2

0

@devShuba monitor your Ajax request in Chrome here is a previous related post Request Monitoring in Chrome

Community
  • 1
  • 1
Haider Ali
  • 800
  • 2
  • 9
  • 22
  • The answer from Ajax is just the complete content of the index.html but I don't know why its always in the else case – devShuba Apr 17 '13 at 16:04
0

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.

reikyoushin
  • 1,993
  • 2
  • 24
  • 40