yii2 输出json的方法
public function actionAjax() { if(isset(Yii::$app->request->post('test'))){ $test = "Ajax Worked!"; // do your query stuff here }else{ $test = "Ajax failed"; // do your query stuff here } // return Json return \yii\helpers\Json::encode($test); }
起点在哪,或许选择不了。重要的是,你追求的终点在哪!