protected function performAjaxValidation($model)
    {
        $result = ($model instanceof Model)
            ? ActiveForm::validate($model)
            : ActiveForm::validateMultiple($model);

        $response = Yii::$app->getResponse();

        if (!empty($result) && $ajaxRedirect = Yii::$app->getSession()->get('site_ajax_redirect')) {
            $response = $response->redirect($ajaxRedirect);
            Yii::$app->getSession()->remove('site_ajax_redirect');
        } else {
            $response->format = Response::FORMAT_JSON;
            $response->data = $result;
        }

        return $response;
    }