我有这个 jQuery 代码:
$("#delete_products").click(function() {
$(":checkbox:checked").each(function() {
var pid = $(this).val();
$.get('delete_product.php',{pid: pid});
});
location.reload();
});
由于某种原因,该$.get()
功能不起作用。当我运行时.fail()
,它确实告诉我它失败了。
这是我的 delete_product.php 页面:
if(isset($_GET['pid']) && !empty($_GET['pid']) && is_numeric($_GET['pid'])){
$pid = $_GET['pid'];
$query = "DELETE FROM `products` WHERE `id` = $pid LIMIT 1";
$query_run = mysql_query($query) or die(mysql_error());
$query = "DELETE FROM `products2categories` WHERE `product_id` = $pid";
$query_run = mysql_query($query) or die(mysql_error());
$pictodelete = ("../products_images/$pid.jpg");
if(file_exists($pictodelete)){
unlink($pictodelete);
}
header("location: index.php");
exit();
}
知道为什么会这样吗?