您好我想在更新数据或从数据库删除数据后重新加载我的数据表的内容。我使用fnDraw()但它不起作用。我使用ajax完成了删除。这是我的代码
ajax.php
<?php
$mysql_host = 'localhost';
$mysql_database = 'proj1';
$mysql_user = 'root';
$mysql_password='';
$mysqli = mysqli_connect($mysql_host, $mysql_user, $mysql_password, $mysql_database);
if (mysqli_connect_errno($mysqli))
{
echo 'Failed to connect to MySQL: ' . mysqli_connect_error();
}
$id=$_POST['id'];
$delete = "delete from regestration_details where eid=".$id."";
$ss=mysqli_query( $mysqli,$delete);
?>
jquery_ajax.js
$('#myTable').on('click','.b2',function()
{
if (confirm("Are you sure?"))
{
var id = $(this).val();
var dataString = {id : id };
$.ajax({
type: "POST",
url: "ajax_delete.php",
data: dataString,
success: function()
{
$("#myTable").dataTable().fnDraw();
alert("datas are successfully deleted..");
},
error: function()
{
alert("Error occured..");
}
});
}
});
对上述问题有任何想法..?