0
我通過jQuery發送POST請求:jQuery的PHP POST錯誤處理
if (isset($_POST['newOwner'], $_POST['uID'])) :
$function->updateTransport($_POST['newOwner'], $_POST['uID']);
endif;
$.post("", {
newOwner: $("#newOwner").val(),
uID: uid
})
我如何登錄jQuery的時候,舉例來說,MySQL不能更新?我試過.fail
,但jQuery總是顯示成功發佈請求。
public function updateTransport($newOwner, $uID)
{
try
{
$stmt = $this->db->prepare("UPDATE cars SET owner= ? WHERE id = ?");
$stmt->execute(array($newOwner, $uID));
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}