echo '<td><a class="delete" href="#" id="'.$row['Id'].'">Delete</a></td>';
<script type="text/javascript">
$(function() {
$(".delete").click(function(){
var element = $(this);
var del_id = element.attr("id");;
var info = 'id=' + del_id;
if(confirm("Are you sure you want to delete this?"))
{
$.ajax({
type: "POST",
url: "ajax_delete.php",
data: info,
success: function(){
}
});
$(this).parents("#checkboxlist").animate({ backgroundColor: "#003" }, "slow")
.animate({ opacity: "hide" }, "slow");
}
return false;
});
});
</script>
ajax_delete.php阿賈克斯同時刪除PHP的MySQL行
<?php
session_start();
include "config.php";
$id=$_REQUEST['id'];
$record = mysql_query("delete from contact_form where Id = '$id'",$con);
if($record)
{
echo '<META HTTP-EQUIV="Refresh" Content="0; URL=list.php">';
$_SESSION['deleted']="yes";
}
else
{
echo mysql_error();
}
?>
不工作我也加入了jQuery庫。試過每一件可能的事情。但桌子不刷新。數據被刪除。但只有刷新頁面時纔會反映出來。我對此感到沮喪。
哪裏可以找到'刪除()'爲元素的功能?我無法在jQuery或JS中找到! –