zoukankan      html  css  js  c++  java
  • tp5项目后台删除

    控制器

    public function bajax(){
            $id = input('id');
            $arr = [];
            $a = db('basgame')->where('id',$id)->select();
            if($a) {
                $arr['code'] = 1;
                db('basgame')->where('id',$id)->delete();
                db('basguess')->where('gid',$id)->delete();
            }
            return $arr;
            //通过Ajax,将传过来的比赛id在数据库中查询,如果有结果,则在比赛和竞猜数据库中都删除掉该记录,再返回数组来确定是否删除成功
        }

    视图html

     <button class="del layui-btn layui-btn-danger" data-id="{$vo.id}">删除</button>
    $('.del').click(function(){
            var id = $(this).data('id');
            var that = $(this);
            layer.confirm('确定删除'+id+'吗?',{icon: 3,title: '提示'},function(index){
              $.ajax({
                //ajax用法
                url:'{:url("index/bnajax")}',
                //与哪个文件进行传递
                type:'post',
                //传递方式
                data:{id:id},
                dataType:'json',
                //返回类型
                success:function(res){
                  //执行函数
                  console.log(res);
                  layer.close(index);
                  if (res.code==1){
                    location.reload();
                  }else{
                    layer.msg('删除失败!');
                  }
                }

              });
            });
          });
  • 相关阅读:
    jdbc学习一半的代码
    实验室的毕业照
    IOS_地图_定位_天气预报_Block回调_单例
    POJ -1062 昂贵的聘礼(前向星 && SPFA)
    【监控】Nagios-NRPE脚本返回值
    cocos2d-x-3.0 Windos 新建项目(coco2d-x 学习笔记一)
    托付与事件
    Netty源代码学习——EventLoopGroup原理:NioEventLoopGroup分析
    vs2013 error c4996: 'fopen': This function or variable may be unsafe
    Customize User Interfaces and Pass User Input to Installer Classes
  • 原文地址:https://www.cnblogs.com/HighKK/p/13496318.html
Copyright © 2011-2022 走看看