当我想要更新textField时遇到问题。我试图通过修改textField上的数据,执行操作并在impatto字段中显示结果后实现ajax解决方案。
查看
<div class="row">
<?php echo $form->labelEx($model,'hhmm'); ?>
<?php echo $form->textField($model,'area',array(
'ajax' => array(
'type'=>'POST',
'url'=>CController::createUrl('impala'),
'data'=>array('hhmm'=>'js:this.value'),
'beforeSend' => 'function(){
var loading=$("<span>")
.attr("class", "ui-autocomplete- loading loading-remove")
.html(" ")
$("#Availability_impatto").after($(loading));
}',
'success'=>'function(data){
$("#Availability_impatto").empty();
$("#Availability_impatto").append(data);
}',
'complete' => 'function(){
$(".loading-remove").remove();
}',
)
)
);
?>
<?php echo $form->error($model,'hhmm'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'percentuale'); ?>
<?php echo $form->textField($model,'percentuale',array('size'=>4,'maxlenght'=>11)).' %';
?>
<?php echo $form->error($model,'percentuale'); ?>
</div>
<div id="impatto" class="row">
<?php echo $form->labelEx($model,'impatto'); ?>
<?php echo $form->textField('Availability[impatto]',
$model->impatto,
array('disabled'=>'disabled','rows'=>5,'cols'=>35, 'class'=>'ui-noborder fieldset-cyan'));
?>
<?php echo $form->error($model,'impatto'); ?>
</div>
控制器
public function actionImpala() {
$impalaval = UtilityHelper::impatur($this->hhmm,$this->percentuale);
echo $impalaval;
Yii::app()->end();
}