title: Chained AJAX dropdown (select) jquery
body: <p>So, recently I have been dabbling a bit in cakephp but I have run into an issue I just can't seem to solve. I suspect it's something simple I'm missing (as most cases). 
  The premise of what I'm trying to do is somewhat self-explanatory in the title: I have a view (my add.ctp) within this add I have a form created with the form helper.</p>
  
  <p>I have multiple selects, the first select is a list of companies. Once the company has been selected, I now want to update the next select based on the selected value using jquery and ajax sending a get request to the controller. </p>
  
  <p>The AJAX request completes successfully however, I cannot seem to access the desirable returned data (a list of projects that belong to the selected company).</p>
  
  <p>To be clear I'm trying to return an array in the success callback</p>
  
  <p>I have read a lot and searched around, but I feel that maybe examples are lacking for v3 cakephp.</p>
  
  <p><i>Some of my code </i>:</p>
  
  <p><b>Controller</b></p>
  
  <pre><code>   $projectphase = $this-&gt;Projectphases-&gt;newEntity();
     $data = ['content' =&gt; 'hi', 'error' =&gt; 'nothing found'];
     $projects = array('0' =&gt; 'Select something');
     if($this-&gt;request-&gt;is('ajax')){
  
          $company_id = $this-&gt;request-&gt;data('company_id');
          $projects = $this-&gt;Projectphases-&gt;Projects-&gt;find('list', ['limit' =&gt; 2, 'conditions' =&gt; ['company_id' =&gt; $company_id]]);
          $arr = array();
          $arr = $this-&gt;chainedProjects($company_id);
          $data = ['content' =&gt; 'hello', 'error' =&gt; ''];
          $this-&gt;set(compact('projects', 'data'));
          $this-&gt;set('_serialize', ['projects', 'data']);
  
     }elseif($this-&gt;request-&gt;is('post')){
  
         debug("hit post");
         die();
     }
  </code></pre>
  
  <p><strong>Public function chainedProjects</strong></p>
  
  <pre><code>    $projects = $this-&gt;Projectphases-&gt;Projects-&gt;find('list', ['limit' =&gt; 2, 'conditions' =&gt; ['company_id' =&gt; $id]]);
      $projs = $projects-&gt;toArray();
      $values = array();
      $x = 0;
      foreach ($projs as $key =&gt; $value) {
           $values[$x] = "&lt;option value='$key'&gt;$value&lt;/option&gt;";
           $x++;
      }
      return $values;
  </code></pre>
  
  <p><strong>Javascript [jquery ajax]</strong></p>
  
  <pre><code>    $(document).ready(function(){
  
      $('#company').change(function () {
          $company_id = $('#company').val();
          var data = {
              'type' : 'dropdown',
              'company_id' : $company_id
          };
          $.ajax({
              type        : 'GET',
              //url       : 'delegate1/projectphases/add',
              data        : data,
              encode      : true,
              beforeSend: function(xhr){
                  xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
              },
              success: function(response){
                  console.log('success');
                  console.log(response.content);
                  console.log(response.message);
  
                  //console.log(data.response);
                  //console.log(result.content);
                  console.log(response);
              }       
          }).done(function(){
              console.log('done');
          })
      });
      })
  </code></pre>
  
  <p>Jquery 2.1.3</p>
  
  <p>Any help whatsoever will be appreciated! </p>