thinkPHP后台实现
#删除用户操作
function delete()
{
if(isset($_SERVER["HTTP_X_REQUESTED_WITH"]) && strtolower($_SERVER["HTTP_X_REQUESTED_WITH"])=="xmlhttprequest"){
$contact_model=M('contact');
$status = $contact_model->where('id='.$_POST['id'])->delete();
if ($status)
{
$data['status']='success';
$data['message']='删除常用联系人成功。';
}
else
{
$data['status']='success';
$data['message']='删除常用联系人失败。';
}
$this->ajaxReturn($data);
}
}
模板文件前台实现
<script type="text/javascript">
function ajaxdelete(id){
//alert(id);
$.post("__APP__/Contactmanage/delete",
{id:id},
function(data){
if (data['status']=="success") {
alert(data['message']);
$('#tr'+id).remove();
}else if (data['status']=="failed")
{
alert(data['message']);
}
},
"json");//这里返回的类型有:json,html,xml,text
}
</script>