i have a dropdownlist
modelA
<?php echo $form->labelEx($model,'type'); ?>
<?php echo $form->dropDownList($model,'type',array('empty'=>'choose refertype','1'=>'typeA','2'=>'typeB','3'=>'typeC')); ?>
<?php echo $form->error($model,'type'); ?>
following is my ajax code what it must do is when i select typeA or any other type it must fetch data from db (depending on the type of modelA data from db of modelB must be fetched )and display in #showdata div which is not working when
$('#modelname_type').change(function(){
if($('#modelname_type').val() == '1'){
$('#showdata').show();
$.ajax(
'url':'Yii::app()->createUrl('controllerB/actionB')',
'type':'get',
'data':array('id'=>$_GET['id']),
'success': function(res){
$("#showdata").html(res);
}
);
$('#codea').hide();
}
});
works only for
$('#modelname_type').change(function(){
if($('#modelname_type').val() == '1'){
$('#showdata').show();
$('#codea').hide();
}
});
Please let me know where am i going wrong please am really stuck from past week am not that strong with ajax
here
if($('#modelname_type').val() == '1'){
change to
var mtype =$('#modelname_type').val();
if(mtype == '1'){
IN AJAX THE
url:'<?php echo Yii::app()->request->baseUrl;?>/index.php/controllerB/actionB/id/"+str';
Will work like a charm