mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-02 13:12:49 +08:00
Controller使用 Transform 编码 JSON 和 xml 数据
This commit is contained in:
@@ -85,16 +85,16 @@ class Controller {
|
||||
case 'JSON':
|
||||
// 返回JSON数据格式到客户端 包含状态信息
|
||||
header('Content-Type:application/json; charset=utf-8');
|
||||
exit(json_encode($data));
|
||||
exit(Think\Transform::jsonEncode($data));
|
||||
case 'XML':
|
||||
// 返回xml格式数据
|
||||
header('Content-Type:text/xml; charset=utf-8');
|
||||
exit(xml_encode($data));
|
||||
exit(Think\Transform::xmlEncode($data));
|
||||
case 'JSONP':
|
||||
// 返回JSON数据格式到客户端 包含状态信息
|
||||
header('Content-Type:application/javascript; charset=utf-8');
|
||||
$handler = isset($_GET[C('var_jsonp_handler')]) ? $_GET[C('var_jsonp_handler')] : C('default_jsonp_handler');
|
||||
exit($handler . '(' . json_encode($data) . ');');
|
||||
exit($handler . '(' . Think\Transform::jsonEncode($data) . ');');
|
||||
case 'SCRIPT':
|
||||
// 返回可执行的js脚本
|
||||
header('Content-Type:application/javascript; charset=utf-8');
|
||||
|
||||
Reference in New Issue
Block a user