title: ZF2: Return JSON only for Ajax Call
body: <p>I'm trying to learn ZF2. I have a page that uses Ajax to get some data. The ZF2 function should return an JSON string. </p>
  
  <pre><code>&lt;?php
  namespace Application\Controller;
  
  use Zend\Mvc\Controller\AbstractActionController;
  use Zend\View\Model\ViewModel;
  use Zend\View\Model\JsonModel;
  
  class DocumentsController extends AbstractActionController {
  
      public function indexAction() {
  
      }
  
      public function getTreeDataAction() {
          $json = new JsonModel(array(
                      'title' =&gt; 'Some Title'
                  ));
          return $json;
      }
  
  }
  </code></pre>
  
  <p>But I keep getting this Fatal Error: </p>
  
  <pre><code>( ! ) Fatal error: Uncaught exception 'Zend\View\Exception\RuntimeException' with message 'Zend\View\Renderer\PhpRenderer::render: Unable to render template "application/documents/get-tree-data"; resolver could not resolve to a file' in ../vendor/ZF2/library/Zend/View/Renderer/PhpRenderer.php on line 451
  </code></pre>
  
  <p>I have been searching around for this error and the best way to make ajax calls in ZF2, however results for ZF1 or ZF2 betas keep coming up and do not work. Thank you for any advice you can give. </p>