工学1号馆

home

tp5 ajaxReturn问题

Wu Yudong    May 08, 2019     ThinkPHP   756   

tp3.2 ajaxReturn 换成tp5的return json($result)

例如 我们需要输出一个JSON数据给客户端(或者AJAX请求),可以使用:

<?php
namespace app\index\controller;

class Index
{
    public function hello()
    {
        $data = ['name' => 'thinkphp', 'status' => '1'];
        return json($data);
    }
}

是不是很简单^-^

如果文章对您有帮助,欢迎点击下方按钮打赏作者

Comments

No comments yet.
To verify that you are human, please fill in "七"(required)