<script>
window.onload = function() {
$(".btn-deladmin").click(function() {
var $id = $(this).parent().parent().attr('id');
$id = $id.substr(3, $id.length - 3);
var html = $.ajax({
type: "post",
url: "ajax.php",
data: "task=deladmin&id=" + $id + "",
error: function() {
alert('error');
},
async: false
}).responseText;
if(html) {
$(this).parent().parent().remove();
}
});
};
</script>
<?php
include('database.php');
if ($_POST['task']=="deladmin")
{
DataBase::connect();
if(DataBase::deladmin($_POST['id']))
{
echo TRUE;
}else{
echo FALSE;
}
DataBase::closeconn();
}
?>
php中返回一个值给ajax判断即可