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
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();
}
?>
I have also added the jquery libraries. Tried every possible thing. But the table does not refreshes. The data is deleted. But reflected only when I refresh the page. I am frustrated with this.