title: PHP Yii Framework and jQuery AJAX getJSON
body: <p>In a view i have an html select element such as</p>
  
  <pre><code>&lt;select id="g" name="g" style="width: 160px; height: 26px; background-color: white; border: 2px solid silver; padding: 0px 4px 0px 4px; box-shadow: 4px #333333;"&gt;
      &lt;option value="value1"&gt;Value1&lt;/option&gt;
      &lt;option value="value2"&gt;Value2&lt;/option&gt;
      &lt;option value="value3"&gt;Value3&lt;/option&gt;
      &lt;option value="value4"&gt;Value4&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>and in the controller i have an action as the follow</p>
  
  <pre><code>    public function actionGetCategories($genre) {
      if(isset($genre)) {
  
          $c = new Category();            
  
          return CJSON::encode($c-&gt;findAll(array(
              'select'=&gt;'category',
              'condition'=&gt;'genre = \'' . $genre .'\''
          )));
      } else {
          return 0;
      }
  </code></pre>
  
  <p>So, i would like that when the user change the select element the application automatically change the elements list of another select element named "c". I have tried to do this by the follow JS code:</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
      $(function () {
          $("#g").change(function () {
              var items = "&lt;option&gt;All categories&lt;/option&gt;";
              var self = $(this);
  
              $.getJSON("&lt;?php echo $this-&gt;createUrl('site/getcategories', array('genre'=&gt;'value')) ?&gt;", 
                  function (data) {
                      $.each(data, function (index, item) {
                          items += "&lt;option&gt;" + item + "&lt;/option&gt;";
                      });
                  $("#c").html(items);
              });
          });
      });
      &lt;/script&gt;
  </code></pre>
  
  <p>But don't works! I have also tried to change the .getJSON url parameter with an complete root URL as "http://localhost/project/index.php?r=site/getcategories&amp;genre=value" but nothing. Can help someone me? </p>
  
  <p>Thanks.</p>