Two call ajax

There was one small problem.

I want to make two calls AJAX.

But this example not work:




echo CHtml::dropDownList('select', '', array(1, 2), array('ajax' => array(

    array(

        'type'   => 'POST'

        'url'    => 'one'

        'update' => '#one'

    ),

    array(

        'type'   => 'POST'

        'url'    => 'two'

        'update' => '#two'

    )

))); 



Please help write true code!

P.S. Sorry for my bad english.

What you’re trying to do makes no sence.

Make it one call and in that action perform the action you wanted for both these ajax calls.

I am know ajax bad. I am use example from "The Yii Cookbook" http://www.yiiframework.com/doc/cookbook/24/

I want to upgrade immediately two dropDownList


echo CHtml::dropDownList('country_id','', array(1=>'USA',2=>'France',3=>'Japan'),

array(

'ajax' => array(

'type'=>'POST',

'url'=>'dynamiccities', 

'update'=>'#city_id' //and update #currency_id

))); 

 

//empty since it will be filled by the other dropdown

echo CHtml::dropDownList('city_id','', array());

echo CHtml::dropDownList('currency_id','', array());



Please help!

You can use ‘success’ instead of ‘update’

Try something like this




echo CHtml::dropDownList('country_id','', array(1=>'USA',2=>'France',3=>'Japan'),

array(

  'ajax' => array(

  'type'=>'POST',

  'url'=>'dynamiccities', 

  'dataType'=>'json',

  'success'=>'js:function(data){$("#city_id").html(data.city);$("#currency_id").html(data.currency); }',

));



in the controller, echo json-encoded html option tags




echo CJavaScript::jsonEncode(array('city'=>$cities, 'currency'=>$currencies));



/Tommy

Thank you!!!