大家好我已经制作了一个图库删除功能,当我开始工作时,我将适应图片报告功能(之后)但是当传递ajax时,功能dosnt在这里做任何事情都是一些代码片段......
用于触发功能的链接
$gallery_list .= '
<div class="pic_holder" onclick="DeletePhoto(\''.$filename.'\')">
<img class="pics" src="user/'.$u.'/'.$filename.'"></a></div>
';
功能
function DeletePhoto(filename) {
var conf = confirm("Press OK to delete this photo.");
if (conf != true) {
return false;
}
_("deletelink").style.visibility = "hidden";
var ajax = ajaxObj("POST", "php_parsers/photo_system.php");
ajax.onreadystatechange = function() {
if (ajaxReturn(ajax) == true) {
if (ajax.responseText == "deleted_ok") {
alert("This picture has been deleted successfully. We will now refresh the page for you.");
window.location = "photos.php?u=<?php echo $u; ?>";
}
}
}
ajax.send("delete=photo&filename=" + filename);
}
和ajax解析器代码
if (isset($_POST["delete"]) && $_POST["filename"] != "") {
$filename1 = preg_replace('#[^a-z0-9]#i', '', $_POST["filename"]);
$query = mysqli_query($db_conx, "SELECT user, filename FROM photos WHERE filename='$filename1' LIMIT 1");
$row = mysqli_fetch_row($query);
$user = $row[0];
$filename = $row[1];
if ($user == $log_username) {
$picurl = "../user/$log_username/$filename";
if (file_exists($picurl)) {
if ($filename != "avatardefault.jpg") {
unlink($picurl);
}
$sql = "DELETE FROM photos WHERE filename='$filename1' LIMIT 1";
$query = mysqli_query($db_conx, $sql);
}
}
mysqli_close($db_conx);
echo "deleted_ok";
exit();
}
任何想法我都做错了什么?因为当我点击按钮时,我得到了确认框,但是当我点击OK时,没有任何反应,ps我真的不希望编辑触发该功能的链接,因为该部分有效,我觉得错误是在其中一个最后两个代码片段。