博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ejs的简单应用
阅读量:7181 次
发布时间:2019-06-29

本文共 2054 字,大约阅读时间需要 6 分钟。

获取数据

var init = function(){    api.my_bean_list({    },function(datas){        console.log(datas);        if (datas.errno){            alert(datas.errdesc);            return;        } else {            var h = new EJS({element:bean_list_ejs}).render(datas);            $('#for_bean_list_ejs').html(h);        }    },function(){        console.log("网络错误");        return;    });};$(function(){    setTimeout(function(){        init();    },500);});

展示数据

间接接口获取数据

public function my_bean_list(){        $json = new Json();        $token = $_POST['token'];        if(!$token) {            $token = $_COOKIE['token'];        }        $uid = $_POST['uid'];        if(!$uid){            $flag = $this->l_intercept();            if(!$flag){                $json->setErr(10015, '用户未登录');                $json->Send();            }            $uid = $_COOKIE['uid'];        }        if(!$uid){            $json->setErr(10015, '用户未登录');            $json->Send();        }        $url = C('MOUSE_HOST') . 'Bean/my_bean_list';        $param = array(            'token'     =>      $token,            'uid'       =>      $uid,        );        $result = Http::doPost($url, $param);        $result = json_decode($result, true);        $this->set_log($param, $result, 'my_bean_list');        if($result['errno'] == 0){            $json->setErr(0,'获取我的5号豆信息成功');            $json->setAttr('my_bean', $result['data']);            $json->Send();        } else {            $json->setErr($result['errno'], $result['errdesc']);            $json->Send();        }    }

直接接口获取数据

/***     * 我的5号豆信息     */    public function my_bean_list(){        $this->checkLogin();        $bean_list = M('BeanList');        $uid = (int)$_POST['uid'];        if (!$uid){            $this->json->setErr('10022','缺少用户信息');            $this->json->Send();        }        $list_flag = $bean_list->where(['uid' => $uid])->order('id desc')->select();        $list_flag = $list_flag ?: [];        $this->json->setAttr('data',$list_flag);        $this->json->Send();    }

转载地址:http://lfszm.baihongyu.com/

你可能感兴趣的文章
[转载]大话MVP
查看>>
2014年总结
查看>>
MyTableWidget
查看>>
Linux常见命令
查看>>
触发Full GC执行的情况
查看>>
docker 自制alpine-lnp镜像
查看>>
C# 当前目录你了解多少
查看>>
国内外知名IT科技博客
查看>>
你不知道的JavaScript(五)内置对象模版
查看>>
Java阶段性总结与获奖感想
查看>>
jQuery(1)
查看>>
iphone 一个强大的动画效果,真的很好,很强大哦
查看>>
第七周(2)
查看>>
Tui-x 命名规则( 转 ) ----- 3
查看>>
SQL Server修改表结构后批量更新所有视图
查看>>
目前流行的源程序版本管理软件和项目管理软件都有哪些,各有什么优缺点?
查看>>
canvas-6font.html
查看>>
jdk9 新特征(译)--3
查看>>
Python 简介
查看>>
Spring AOP
查看>>