Yii::$app->response->format = Response::FORMAT_JSON;
        $data = User::find()->where([])->asArray()->one();
        return ['code'=>200, 'msg'=>'成功','data'=>$data];    

结果 使用ajax 获取的数据 console.log()出来

Yii2控制器 返回 json 格式数据

相关文章:

  • 2021-10-18
  • 2021-08-05
  • 2023-03-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-28
猜你喜欢
  • 2021-08-22
  • 2022-12-23
  • 2022-01-15
  • 2022-12-23
  • 2022-12-23
  • 2021-08-11
  • 2022-12-23
相关资源
相似解决方案