php - How can I use ajax in Zend Framework 2? -
i trying little ajax application whereby want homecoming hello world string controller action. returning hello world along this, returning template file.. tried disable templating using next code in action of controlelr
$this->_helper->layout()->disablelayout(); $this->_helper->viewrenderer->setnorender( true );
but returns me error
scream: error suppression ignored ( ! ) 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 ( ! ) fatal error: phone call fellow member function layout() on non-object in c:\wamp\www\zend\module\survey\src\survey\controller\surveycontroller.php on line 55 phone call stack
how prepare ?
edit
i modifed controller such looks
public function registeraction() { $result = new jsonmodel(array( 'some_parameter' => 'some value', 'success'=>true, )); return( $result ); }
added strategies in module..module.config in module appl directory
'strategies' => array( 'viewjsonstrategy', ),
still, in ajax response template beingness returned
here's solid example:
http://akrabat.com/zend-framework-2/returning-json-from-a-zf2-controller-action/
you should using jsonmoodels send json response.
php zend-framework2
No comments:
Post a Comment