D
D
dev4002017-01-03 15:40:31
JavaScript
dev400, 2017-01-03 15:40:31

How to give json in yii2 and process it in the view?

I want to receive and send data to the server asynchronously in the application. So that the server just gives json. What are the solutions?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Toey, 2017-01-03
@dev400

I use yours like this

public function actionTest(){
    \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
    $data = ['id'=>2,'text'=>'zzz'];
    return $data;
}

details can be read here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question