您好,我有这个问题...
if (isset($_REQUEST['deletePost'])) {
$q = $dbc -> prepare("DELETE FROM boardposts WHERE postID = ? AND parentID = ?");
$q -> execute(array($_REQUEST['deletePost'], $_REQUEST['deletePost']));
}
我从我的 js 发出的请求称为 deletePost
并且附带的 id 是正确的。
为什么这会像现在这样失败?
我的js是这样的
$('.deletePost').click(function() {
var id = $(this).attr('id');
$.ajax({
data: {
deletePost: id
},
success: function() {
$('.content').empty().html('<p>The selected post and all of its children have been deleted.</p>');
}
});
return false;
});
它返回成功调用,我网站上的所有其他 ajax 都工作正常。 ajax 的设置在别处定义。
最佳答案
因为您的查询看起来有误。不应该是 WHERE postID = 吗?或者 parentID = ?
?
关于php - 删除 mysql 不能通过 ajax 工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8697608/