Hello,
I try to do this example http://www.prettyscripts.com/ajax/yii2-processing-jquery-ajax/
public function actionAjax() {
Yii::$app->response->format = Response::FORMAT_JSON;
$post = Yii:: $app->request->post();
$data = [];
if (Yii::$app->request->isAjax) {
// do your data processing here
// set response data
if (success) {
$data = ['sucess' => true, /* rest of the data */];
}
else {
$data = ['success' => false, 'error' => 'Some error message'];
}
return $data;
}
}
but it gives me the following error
<< Class ‘app \ controllers \ Response’ not found >>
I have tried with
use yii \ web \ Response
Yii :: $ app-> response-> format = use yii \ web \ Response :: FORMAT_JSON;
use yii \ helpers \ Json;
And several other things but I always get an error
Where this error?
Do I have to install something with composer?
Greetings.