forgot to put “‘dataType’=> ‘json’,”. case closed.
is it possible by using ajax, the array value from controller then to be used in many textfield. how to do that.
controller
<?php
public function actionCalculateTotal(){
$total = (!empty($_POST['total'])) ? $_POST['total'] : 0;
$unformatTotal = Yii::app()->format->unformatNumber($total);
//$data = Yii::app()->format->number($unformatTotal);
//if (!empty($data)) { echo CHtml::encode($data); }
$data = array('test1'=>'9876','test2'=>Yii::app()->format->number($unformatTotal));
foreach($data as $itemData){
echo CHtml::encode($itemData);
}
}
?>
=========
_form
<?php
echo $form->textFieldControlGroup($model,'total',
array(
'ajax' => array(
'type'=>'POST',
'url'=>Yii::app()->createUrl('tx/installation/CalculateTotal'),
'update'=>'#Installation_discount_nominal',
'data'=>array('total'=>'js:this.value'),
'success'=>' function(data) { '
. '$(\'#Installation_discount_nominal\').val(0),'
. '$(\'#Installation_payment\').val(data[0]),'
. '$(\'#Installation_balance\').val(0)'
. '}',
)),
array('maxlength'=>18)
);
?>
=========
. ‘$(\’#Installation_payment\’).val(data[0]),’ outputs is “9”, but i want it to be “9876” (see controller). how to do that?
thank you