[ask] about json in combo box

hello…

i want to make a combo box when I select the advertiser, the product combo box contents will change (according to the selected combo_box_advertiser).

and textfield job_id will changed to the name of the advertiser selected

I’ve tried using JSON but not successful

help me please…

my code:

Batch /_form





<div class="form">


<?php $form=$this->beginWidget('CActiveForm', array(

	'id'=>'batch-form',

	'enableAjaxValidation'=>true,

)); ?>


	<p class="note">Fields with <span class="required">*</span> are required.</p>


	<?php echo $form->errorSummary($model); ?>


		<div class="row">

		<?php echo $form->labelEx($model,'jobs_id'); ?>

		<?php echo $form->textField($model,'jobs_id',array('size'=>50,'maxlength'=>50)); ?>

		<?php echo $form->error($model,'jobs_id'); ?>

	</div>

	

	<div class="row">

		<?php echo $form->labelEx($model,'id_advertiser'); ?>

		<?php echo $form->dropDownList($model,'id_advertiser',CHtml::listData(Advertiser::model()->findAll('deleted IS NULL or deleted <> :deleted',array(':deleted'=>1)), 'id', 'name'),

		array('empty'=>'--Please Choose One--'),

		array(

            	'type'=>'POST', 

            	'dataType'=>'json',

            	'data'=>array('id_advertiser'=>'js:$(\'#Batch_id_advertiser\').val()'),//-->is this correct??

            	'url'=>CController::createUrl('dodo'),

            	'success'=>'function(data) {

            	$("#Batch_id_product_category").html(data.dropdownA);

         		$("#Batch_jobs_id").html(data.id_advertiser);

            	}',

			)

		); ?>

		<?php echo $form->error($model,'id_advertiser'); ?>

	</div>


	<div class="row">

		<?php echo $form->labelEx($model,'id_product_category'); ?>

		<?php echo $form->dropDownList($model,'id_product_category',array()); ?>

		<?php echo $form->error($model,'id_product_category'); ?>

	</div>

<div class="row buttons">

		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>

	</div>


<?php $this->endWidget(); ?>


</div><!-- form -->




BatchController:

.





public function actionDodo()

{

	$id_advertiser = Yii::app()->request->getParam('id_advertiser');


	$data=AdvertiserCategory::model()->findAll('id_advertiser=:parent_id', 

	array(':parent_id'=>(int)$id_advertiser));

	

	$data=CHtml::listData($data,'id_product_category','id_product_category');


			foreach($data as $value=>$id_product_category)

		{         

  			$dropDownA .= CHtml::tag('option', array('value'=>$value),CHtml::encode($id_product_category),true);

  		}                 

			// return data (JSON formatted)

			echo CJSON::encode(array(

				  	'dropDownA'=>$dropDownA,

				  	'id_advertiser'=>$id_advertiser,

			)); Yii::app()->end();


	

}	

}






anyone please help me:blink:

Have you checked your JSON output? Is it correct?

how to check the json output?

echo?

Using firebug. Or if you use Chrome, I think you can check it under ‘Network’ tab.

i use error console

I get an error

but I did not write this code–> [,‘cache’:false}]

what does this mean?[i][u][b]

[/b][/u][/i]

i using mozila console

when I select the combobox I run the [action Dodo] but in mozilla writings actionDodo 500 error when on the run

[[10:04:12.253] POST index.php? R = batch/dodo [HTTP/1.0 500 PHP Error 125ms]]

but if i delete echo CJSON:: encode from actionDodo in controller i not get an error

json code in my controller





echo CJSON::encode(array(

					  'dropDownA'=>$dropDownA,

					  'id_advertiser'=>$id_advertiser,

			)); 

			




what does this mean?[i][b]

[/b][/i]