Yii 如何让response是json? 就像$response->setHeader(‘Content-Type’, ‘application/json’)
Yii 如何让response是json? 就像$response->setHeader(‘Content-Type’, ‘application/json’)
echo json_eoncde(array(1,2,3));
Yii::app()->end();
谢谢。但这样不是application/json格式啊。。 还包含html标签
你试试看这个是否可以用
CJSON::encode($var)
json就无所谓头部信息了吧?
把布局去掉就没有html内容了
$this->layout=false;
$this->layout=false;
header(‘Content-type: application/json’);
echo json_encode($arr);
Yii::app()->end();