When using ajax and json formatting, I am encountering this message. In PHP, the code array("message" => "Success", "data" => $data) is displayed successfully. However, it is not able to callback to ajax. How can I resolve this issue without deleting the datatype "json"? Please assist me.
success: function(Return)
{
if (Return.message === 'Success') {
window.location = "Homepage.html";
}
else {
window.alert("No such account or wrong password");
}
},
error: function(xhr, textStatus, error){
console.log(xhr.statusText);
console.log(textStatus);
console.log(error);
}
$result = $conn->query($sql);
$data = $result->fetch_assoc();
if ($data)
{
echo json_encode
(
array("message" => "Success", "data" => $data)
);
}
else
{
echo json_encode
(
array("message" => "Fail")
);
}