function register_ajax() { $this->layout = 'ajax'; if (!empty($this->data)) { $error = $this->checkUserData($this->data, true); } else { $error = new MyError('no_error'); } echo $error->getJSON(); }