Ajax 无刷新技术 【 有get 和post 一一对应】
$(".delete").click(function () {
cf=confirm("确认删除");
if (!cf) {
return false
}
id=this.id;
obj=$(this);
// var r;
$.get('delete.php',{id:id},function (r) {
// console.log(r);
// alert(r)
if (r==1) {
// alert(1)
obj.parent().parent().fadeOut(100);
}
})
})
$id=$_POST['id'];
//用php去数据库删除数据
$pdo=new PDO('mysql:host=localhost;dbname=houtaiab','root','Aa425');
$pdo->exec('set names utf8');
$sql="delete from patient_18 where id=$id";
if($pdo->exec($sql)){
echo 1;
}else{
echo 0;
}
?>
转载于:https://www.cnblogs.com/nice2018/p/10699898.html