title: Simple AJAX / JSON response with CakePHP
body: <p>I'm new to cakePHP. Needless to say I don't know where to start reading. Read several pages about AJAX and JSON responses and all I could understand is that somehow I need to use <code>Router::parseExtensions()</code> and <code>RequestHandlerComponent</code>, but none had a sample code I could read.</p>
  
  <p>What I need is to call function <code>MyController::listAll()</code> and return a <code>Model::find('all')</code> in <code>JSON</code> format so I can use it with JS.</p>
  
  <p>Do I need a <code>View</code> for this? 
  In what folder should that view go? 
  What extension should it have?
  Where do I put the <code>Router::parseExtension()</code> and <code>RequestHandlerComponent</code>? </p>
  
  <pre><code>// Controller
  public function listAll() {
      $myModel = $this-&gt;MyModel-&gt;find('all');
  
      if($this-&gt;request-&gt;is('ajax') {
          $this-&gt;layout=null;
  
          // What else?
  
      }
  }
  </code></pre>