Commit 89dc771c authored by tufengqi's avatar tufengqi

新增老的json输出

parent f7dfd968
...@@ -134,6 +134,28 @@ class ResponseApi ...@@ -134,6 +134,28 @@ class ResponseApi
} }
} }
/**
* @param $json_str
* @param $callback_key
*/
public static function printOldSuccess($success_data, $callback_key = '')
{
$callback = '';
if ($callback_key) {
$callback = $_GET[$callback_key] ?? '';
}
$arr = ['code' => 200, 'error' => 'OK', 'message' => 'OK', 'data' => $success_data];
if ($callback) {
$callback = Html::encode($callback_key);
self::header('Content-type', 'application/javascript');
echo $callback . '(' . json_encode($arr) . ')';
} else {
self::header('Content-type', 'application/json');
echo json_encode($arr);
}
}
public static function header($key, $value) public static function header($key, $value)
{ {
if (1 != \Yii::$app->request->get('debug')) { if (1 != \Yii::$app->request->get('debug')) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment