public function actionCreate() { $m = new Model(); $r = Yii::$app->request; if ($r->isAjax) { $m->menu = $r->post('menu'); \Yii::$app->response->format = Response::FORMAT_JSON; return ['success' => $m->save(), 'url' => Url::to(['index'])]; } else { return $this->render('create'); } }