如何通过使用 jquery ajax 调用传递 id 来删除一行,这是 delete.php
<?php
require_once('DB.class.php');
$dbconnect = new DB('schoollife', 'root', '');
$id=$_GET['chapter_id'];
$del="DELETE FROM sl_chapter WHERE chapter_id=".$id ;
$result=mysql_query($del);
// if successfully deleted
if($result){
echo "<font color='red'>record deleted successful</font>";
//echo "<BR>";
//echo "<a href='delete.php'>Back to main page</a>";
}
else {
echo "<br/>";
die('Error: ' . mysql_error());
}
?>
这是章节.html
<script>
$(document).on('click','.delbutton',function(){
var del_id = element.attr("id");
var info = 'id=' + del_id;
if(confirm("Are you sure you want to delete!"))
{
$.ajax({
type: "json",
url: "delete.php",
//data: info,
success: function(){
}
});
$(this).parents(".record").animate({ backgroundColor: "#fbc7c7" }, "fast")
.animate({ opacity: "hide" }, "slow");
}
return false;
});
</script>
如何通过仅使用 jquery ajax 调用传递 id 来删除一行我认为删除查询确实出错了..