<p class="id" b_id="{$val['b_id']}">删除</p>
$('.id').click(function (){ var b_id = $(this).attr('b_id'); var that = $(this); $.ajax({ url:'del', data:{b_id:b_id}, type:'get', success:function (res){ if(res.code == '200'){ that.parents('tr').remove(); } } }) })
控制器
public function del() { //接收ID $b_id = request()->get('b_id'); //dd($b_id); //实例化模型层 $model = new \app\model\showList(); //想模型层传递ID的值 $data = $model->del($b_id); return json(['code'=>'200','msg'=>'删除成功']); }
模型层
public function del($b_id) { return $this->where('b_id',$b_id)->delete(); }