Yii Redirect not working

I have registration from where the user enters their email address and then clicks join. The submit button triggers the an email validation action and then is supposed to redirect to another page, where the registration can continue but this doesn’t occur. I get this error:

SyntaxError: missing ) in parenthetical

[Break On This Error] 	


Here’s the action that’s being called

public function actionValidateEmailAjax() {

 		$model = new RegisterStartForm;



		$response = array();

		if ($model->hasErrors()) {

			$response['good'] = 0;

			$response['error'] = end(end($model->getErrors()));

			echo json_encode($response);


		} else {

			$response['good'] = 1;

			$response['email'] = $model->getEmail();


			echo json_encode($response);





I think the error occurs because the view file that users/search renders is a mix of html and php but I don’t know what to do about it. I should admit I’m also a relatively new yii user.

Since this is an Ajax request, then why do you have that line in your controller? Maybe commenting it out would help you get rid of the error?

Sorry it should say


I was getting so frustrated with this error that I started trying different things and I guess I didn’t catch my change.


terminates application immediately so

echo json_encode($response)

wil never be executed.

  1. Browsers can’t be redirected by an ajax response. It should be done on client side.

  2. What’s the point of using ajax when you want to load another page anyway?

Well the ajax is for verification to affirm the field is correct but when I tried to use

window.location.href='<?php echo CHtml::normalizeUrl(array('/users/search')); ?>';

in the ajax success part it wouldn’t work.