Always Returns Error In Jquery Json Call

Hello everyone.

Im doing an autoComplete Jquery, and on select it calls an action in controller:

views\index.php




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

				'name'=>'test2',

				'source'=> $arrayServices,

				'options'=>array(

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

						$.ajax({

						   type: "GET",

						   dataType: "json",

						   url: "index.php?r=SEMAFOROS/index",

						   data: {FiltersForm: ui.item.value},

						   success: function(data){

								alert('ok');					

						   },

						   error: function (jqXHR, textStatus, errorThrown) {

								alert(textStatus);

								alert(errorThrown);

							},

						 });

					}',

				),

			  ));




in my controller:




if (isset($_GET['FiltersForm']))

{

   $response = array('return', 'msg', 'idk');

   echo CJSON::encode($response);

}



It seems ok to me but the return of jquery call is always an error calling the function of error. What is my problem?

appreciate any tips :)

Dear Friend

I checked your code in my localhost , it works well.




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

                                'name'=>'fruit',

                                'source'=> array("apple","banana","cherry","pineapple","orange"),

                                'options'=>array(

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

                                                $.ajax({

                                                   type: "GET",

                                                   dataType: "json",

                                                   url: "'.CHtml::normalizeUrl(array("test/auto")).'",

                                                   data: {"test": ui.item.value},

                                                   success: function(data){

                                                          console.log(data[0]);                                   

                                                   },

                                                   error: function (jqXHR, textStatus, errorThrown) {

                                                                console.log(textStatus);

                                                                console.log(errorThrown);

                                                        },

                                                 });

                                        }',

                                ),

                          ));



TestController.php




public function actionAuto()

{

		//echo $_GET['test'];

		$response = array('return', 'msg', 'idk');

		echo CJSON::encode($response);


}		



It prints




return



in my console.

It also works without declaring dataType.(Jquery make intelligence guess)

In that case use JSON.parse() to get the elements in the data.

Note:You have put ok in single quotes. But anyway it may have thrown php error.

Regards.

thank you for your time seenivasan.

I saw the problem lol. In my controller i had a var_dump to check my action :P didnt know but it screwed up.

[SOLVED]