1、返回json数据
public function demo1() { $data = 'ok'; $this->ajaxReturn($data); }
public function demo2() { $data['status'] = 1; $data['content'] = 'content'; $this->ajaxReturn($data); }
2、返回jsonp数据
$Model = new Model(); $sql = "select * from tbrecord order by recordid asc"; $list = $Model->query($sql); $this->ajaxReturn($list,'jsonp');
jsonp的头默认是jsonpReturn,可以在请求页面的时候添加callback变量,改变这个默认值,如page?callback=abc