jquery代码
<script> $(function () { $(".del").click(function () { var id=$(this).attr("name"); $("input[name='del_id']").val(id); }); $("#delete").click(function () { var id=$("input[name='del_id']").val(); $.post('<?=U('product/delete')?>',{id:id},function (rs) { if (rs.status==1){ $('#Modal-delete').modal('hide'); layer.msg(rs.info); location.reload(); } },"json") }); // $("#example1").DataTable(); }) </script>controller代码 关闭csrf
public function beforeAction($action) { $currentAction = $action->id; $currentActions = ['article_delete']; if(in_array($currentAction,$currentActions)) { $action->controller->enableCsrfValidation = false; } parent::beforeAction($action); return true; }
/** * 直播表的删除 把为1的status改为0 * @auth magang * @time 2017/5/26 18:18 */ public function actionArticle_delete(){ $id = Th::request()->post(); if(!empty($id)){ $User = Broadcast::findOne($id); $User->status = '0'; if($User->save()){ $this->info("删除成功!",1); } }else{ $this->info("无法获取数据!",0); } }