2678777127 发表于 2018-2-11 12:11:13


            本文实例讲述了yii2使用ajax返回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);
}
页: [1]
查看完整版本: yii2使用ajax返回json的实现方法