-1
使用ajax和json格式。但它發生這些消息。在PHP中,可以成功顯示數組(「message」=>「Success」,「data」=> $ data)。但它不能回調到Ajax。我如何解決它。請幫幫我。我不想刪除數據類型「json」。SyntaxError:位置0處JSON中的意外標記C(...)
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")
);
}