title: How can I use ajax in Zend Framework 2?
body: <p>I am trying a small ajax application whereby I only want to return a hello world string from my controller action.
  it is returning the Hello world but along with this, it is also returning my template file..
  I tried to disable it the templating using the following code in the action of my controlelr</p>
  
  <pre><code>$this-&gt;_helper-&gt;layout()-&gt;disableLayout();
  $this-&gt;_helper-&gt;viewRenderer-&gt;setNoRender( true );
  </code></pre>
  
  <p>but this returns me this error</p>
  
  <pre><code>SCREAM: Error suppression ignored for
  ( ! ) Notice: Undefined property: Survey\Controller\SurveyController::$_helper in C:\wamp\www\zend\module\Survey\src\Survey\Controller\SurveyController.php on line 55
  
  SCREAM: Error suppression ignored for
  ( ! ) Fatal error: Call to a member function layout() on a non-object in C:\wamp\www\zend\module\Survey\src\Survey\Controller\SurveyController.php on line 55
  Call Stack
  </code></pre>
  
  <p>How do I fix this ?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I modifed the controller such that it looks like this </p>
  
  <pre><code>public function registerAction()
  {
      $result = new JsonModel(array(
          'some_parameter' =&gt; 'some value',
          'success'=&gt;true,
      ));
  
      return( $result );
  }
  </code></pre>
  
  <p>Added strategies in the module..module.config in module appl directory</p>
  
  <pre><code>'strategies' =&gt; array(
      'ViewJsonStrategy',
  ),
  </code></pre>
  
  <p>Still, in the ajax response I get the template being returned</p>