php ajax confirm 删除实例详解
本文主要介绍了php ajax confirm 删除实例,分享给大家,也给自己留个笔记,具体如下:
<button name="del" type="button" class="btn btn-primary btn-xs" id="del">删除</button>
$("button[name=del]").click(function(){ var statu = confirm("确定删除吗?"); if(!statu){ return false; } var operation = {$res.id}; $.ajax({ type:'POST', url:"{:url('Sections/del')}", data:{idd:operation}, success:function(msg){ if(msg == 1){ alert( '删除成功' ); location.reload(); }else{ alert( '删除失败,请稍后重试' ); } }, error:function(){ alert( '删除失败,请稍后重试' ); } }); });
public function del() { $id=input('post.idd'); $res = $this->section->del($id); echo json_encode($res); } /** * 删除 */ public function del($id) { $res = Section::destroy(['id' => $id]); return $res; }
相关推荐
LuAndy 2020-08-15
powrexly 2020-07-20
loviezhang 2020-06-16
songerxing 2020-01-04
wangyjbk 2019-12-27
itjavashuai 2019-12-15
zhaijunliang00 2019-11-24
zhihuijiao 2019-11-19
whutjiajiao 2019-09-08
waitzkj 2019-01-26
WoogeYu 2019-01-26
Ping 2019-07-01
shixiaoguo0 2017-05-09
heavstar 2019-06-30
Mrwind 2019-06-27
数据库之扑朔迷离 2019-06-26
xiaocaibai 2013-12-12
XaverSun 2013-11-15