Here is my success function for my ajax request via jquery,
success: function(response) {
if (response.error == undefined) {
alert(response);
}
$('#' + id).after('<div id="emailMsg" class="error">' + response.error + '</div>');
}
Because the value is coming back as undefined it alerts me the returned JSON which is...
{"error":true}
Why is this happening, surely when I call response.error I should get either true or false.
UPDATE
Variable is returning as a string and not boolean, my json_encode();
if (!$q -> rowCount()) {
echo json_encode(array('error' => false));
}
else {
echo json_encode(array('error' => true));
}