Here is a ajax call i did in my php file :
$.ajax({
type: "POST",
url: "../includes/filters.php",
data: {"email" : email},
dataType: "json",
success: function(data)
{
if(data.equals('sent'))
{
alert(data);
}
else
{
alert("There Was Some Problem Please Try Again!");
}
},
error: function(xhr, status, text) {
console.log(xhr);
console.log(status);
console.log(text);
}
});
and here is the filters.php file :
$email = $_POST['email'];
$email = filter_var($email, FILTER_VALIDATE_EMAIL);
$query = "---------some query------";
$stmt = $mysqli->prepare($query);
$stmt->bind_param("s", $email);
$stmt->execute();
$stmt->store_result();
$temp = $stmt->num_rows;
if ($temp == 1)
return json_encode('true');
else
return json_encode('false');
here is the error i am getting in the consol
Object {readyState: 4, responseText: "", status: 200, statusText: "OK"}
(index):120 parsererror
(index):121 SyntaxError: Unexpected end of input
at Object.parse (native)
at n.parseJSON (http://localhost/pedagoge/assets/plugins/jquery/jquery-2.1.4.min.js:4:5497)
at ub (http://localhost/pedagoge/assets/plugins/jquery/jquery-2.1.4.min.js:4:7521)
at x (http://localhost/pedagoge/assets/plugins/jquery/jquery-2.1.4.min.js:4:10935)
at XMLHttpRequest.n.ajaxTransport.k.cors.a.crossDomain.send.b (http://localhost/pedagoge/assets/plugins/jquery/jquery-2.1.4.min.js:4:14765)
please help me out, since i have already tried all the JSON conversion, i even tried converting a php variable with a string in it, no lead
data.equals()? Are you confusing Javascript with Java?