I've googled quite much, but cant get solution. The problem is, that when I use my action to return JSON data (no view created for it) the reciving it jquery script throws an error 200 ("SyntaxError: JSON.parse: Unable to parse value: <!DOCTY" - seems that recived data from called zend action is just html).
I found out, that I need to disable rendering for this view.
so my action looks like this:
Code: Select all
$this->_helper->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); //do some stuff echo Zend_Json::encode(array('result' => 'success'));
Code: Select all
$ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext->addActionContext('savequestions', 'json')->initContext();
the only thing is, when I go to url navigating to this zend JSON returning action in browser, I get error:
Fatal error: Uncaught exception 'Zend_Loader_PluginLoader_Exception' with message 'Plugin by name 'Layout' in ....
( ! ) Zend_Loader_PluginLoader_Exception: Plugin by name 'Layout' was not found in the registry; used paths: Zend_Controller_Action_Helper_: Zend/Controller/Action/Helper/ in ...
I dont use any helpers (I dont know why would I, I am begginner and didnt need to use any helpers yet). I read that I should set helpers path in bootstrapper, but someone also wrote that this is done defaultly anyway.
Can someone help me? It is really difficult for me to understand why (if I should) should I create empty helper just to block it? Or maye, someone could write the correct code (complete, couldn't find such in google) to make jquery ajax queries in zend without helpers?