i am having two ajax request in a form when the first is clicked it is working correctly…when the second one is clicked it also also displays the result of the first along with second how do i avoid this problem…do someone help me
i am having two ajax request in a form when the first is clicked it is working correctly…when the second one is clicked it also also displays the result of the first along with second how do i avoid this problem…do someone help me
could you put your code?
<?php echo CHtml::form(); ?>
<?php echo CHtml::errorsummary($form);?>
<?php echo CHtml::dropDownList('standard',$std,CHtml::listdata(ClassMaster::model()->findAll(),'standard','standard'),array('ajax'=>array(
'type'=>'POST','url'=>CController::createUrl('exam/examconfigurationadd'),'update'=>'#test')));?></td>
<?php echo CHtml::dropDownList('section','',array(),array('prompt'=>'select…','ajax'=>array('type'=>'POST','url'=>CController::createUrl('exam/examconfigurationadd'),'update'=>'#subject')));?>
<?php echo CHtml::dropDownList('subject','',array(),array('prompt'=>'select…'));?>
and the code in action contoller is
if(Yii::app()->request->isAjaxRequest)
{
if(isset($_POST['standard']))
{
$section=CHtml::listData(ClassMaster::model()->findAll('standard=:standard',array(':standard'=>$_POST['standard'])),'section','section');
foreach($section as $value=>$section)
{
echo CHtml::tag('option',
array('value'=>$value),CHtml::encode($section),true);
}
}
if(isset($_POST['standard'])&&($_POST['section']!='null'))
{
$id=ClassMaster::model()->find('standard=:standard and section=:section',
array(':standard'=>$_POST['standard'],':section'=>$_POST['section']));
$standard=CHtml::listData(SubjectMaster::model()->findAll('classid=:classid',array(':classid'=>$id->id)),'subjectname','subjectname');
foreach($standard as $value=>$standard)
{
echo CHtml::tag('option',
array('value'=>$value),CHtml::encode($standard),true);
}
}