Redirecting or Calling another controller from javascript

Dear All,

Could some one please give me the correct syntax to call controller from Java script?

Here is the case , I have below code . In auto complete after selecting the value I want to pass the selected value and drop down value ( the first line in the code) to some other controller . Could some one please let me how to do this ( Not using ajax call , I want to redirect to that controller) ? I have put alert(ui.item.value) statement temporarily on select event …

Thank You


<?php echo CHtml::dropDownList('type','',array('1'=>'Company','2'=>'Profession','3'=>'People')); ?>


<?php


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

	'name'=>'searchAuto',

	'id'  => 'searchAuto',

	'value' =>'Search',

   'source'=>'js: function(request, response) {

	   $.ajax({

		   url: "'.$this->createUrl('myAutoComplete/autoCompleate').'",

		   dataType: "json",

		   data: {

			   term: request.term,

			   brand: $("#type").val()

		   },

		   success: function (data) {

				   response(data);

		   }

	   })

	}',

	 'options' => array(

		'showAnim' => 'fold',

		'minLength' => '2',

		'select' => 'js:function(event, ui){ alert(ui.item.value) }',

	 ),


	 'htmlOptions' => array(

	     'onFocus' => 'document.getElementById("searchAuto").value=""'

	 )




));

To redirect from javscript… use "window.location=<your url>"

Thanks lot . I shouldn’t even have asked :( . Early morning syndrome

What might be the trouble if this doesn’t work?

in my javascript function I do: window.location="index.php?r=reports/all"

The resulting Request URL seems to be: "index.php?" (the "r=controller/action" part gets stripped out)

Is this an .htaccess problem?

– This is a YII config problem requiring the use of the URL manager.

So uncomment that section in the config/main.php file.

Use a form "action=", and use the javascript just to validate the form, not forward it.

e.g.

<FORM name=‘nameForm’ action="/index.php/reports/all" onSubmit=“return validateNameForm()” />