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('删除失败!');
                  }
                }

              });
            });
          });
  • 相关阅读:
    Unity打包ARCore项目失败,但是其他安卓项目成功
    关于Unity 图片队列存储以及出列导致内存溢出的解决方案
    unity 使用 outline 组件
    7Z解压工具的BUG
    Unity ILRuntime 调用方法一览
    Python 免费插件
    SQL经典面试题及答案
    PL/SQL Developer中文注释乱码的解决办法
    Tomcat并发优化和缓存优化
    在配置hibernate.cfg.xml时需指定使用数据库的方言:
  • 原文地址:https://www.cnblogs.com/HighKK/p/13496318.html
Copyright © 2011-2022 走看看