CJuiAutoComplete Not Completing With Ajax


I’ve been struggling with it for a few days so any help would be more than welcomed.

The problem : The plugin will autocomplete the text input if I provide a static array of string. It will get an answer back from my ajax call when using remote source but won’t use the data to generate the autocomplete list.

The code so far :

An extension called AutoCompletionAction :


	class AutoCompleteAction extends CAction


		public $model;

		public $attribute;

		public $fields;

		private $results = array();

		public function run()


			if(isset($this->model) && isset($this->attribute))



					$this->fields = array($this->attribute);

				$criteria = new CDbCriteria();

				$criteria->compare($this->attribute, $_GET['term'], true);

				$model = new $this->model;

				$row = array();


				foreach($model->findAll($criteria) as $m)


					foreach($this->fields as $field)

						$row[$field] = $m->{$field};

					$this->results[] = $row;



			echo CJSON::encode($this->results);




It is added to a Controller this way :

public function actions() {

	return array(









And the clientside call is made like this :


	$this->widget('zii.widgets.jui.CJuiAutoComplete', array(







			'select' => 'js:function(event, ui) { 








	echo $placeForm->hiddenField(Place::model(), 'id_place');


Lastly, here is the json I’m getting back in the browser :

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">









As you can see, the code is quite simple. I’m just wondering why json isn’t used by the plugin…

Well I guess the HTML wrap up is what’s causing the issue. Any idea on how prevent Yii from adding that ?

I tried to add a layout=‘none’, but it didn’t work…