title: how to change values in a dropdown list using ajax in Yii
body: <p>in view page i have 2 dropdown</p>
  
  <pre><code>&lt;?php
  $list = CHtml::listData($category, 
                  'cid', 'cname');    
  echo $form-&gt;dropDownList($model,'cid',$list,
                array('empty' =&gt; '(Select a category)')); 
  ?&gt; 
  &lt;label&gt;Sub Category *&lt;/label&gt;
  &lt;?php  
  $subcategory = array();
  echo $form-&gt;dropDownList($model,'sid',$subcategory,
                array('empty' =&gt; '(Select a subcategory)')); 
  ?&gt; 
  </code></pre>
  
  <p>Using value from category i have to change subcategory values</p>
  
  <p>Here is my ajax function</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(function (){ 
          $("#Product_cid").change(function (){             
              var cid = $('#Product_cid').val();
              var path = "&lt;?php echo $this-&gt;createUrl('admin/mysubcategory') ?&gt; ";
              $.ajax({  
              type: "POST",      
              url: path, //url to be called
              data: { cid: cid } //data to be send 
              }).done(function( msg ) {
                   alert(msg)
                   $("#Product_sid").val("msg");
                   $("#Product_sid").selectmenu('refresh'); 
  .
               });
  
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>And here is my controller</p>
  
  <pre><code>public function actionMysubcategory()
  {
          $cid = Yii::app()-&gt;request-&gt;getPost('cid'); 
          $subcategory= Subcategory::model()-&gt;findAll(
                  array('order'=&gt;'sid',
                 'condition'=&gt;'cid=:cid', 
                 'params'=&gt;array(':cid'=&gt;$cid)));
              $list = CHtml::listData($subcategory, 
              'sid', 'sname');    
  
          print_r($list);
  } 
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/8WEJS.png" alt="enter image description here"></p>
  
  <p>I gets list from controller. How can make into a dropdown???</p>