我有一个控制器,我想用于ajax脚本来调用和设置会话变量,获取信息等。我如何设置它,以便该特定控制器不使用默认布局(特别是没有布局),以便它可以来回发送XML / JSON消息?
Like anything to do with Zend_Framework and Zend_Application, there are multiple ways to do this, but on the last few pure Zend gigs I've done, I've seen people using the following (from an action method in you controller)
$this->_helper->layout()->disableLayout();
This shuts off of the layout. If you wanted to turn off your view as well, you could use
$this->_helper->viewRenderer->setNoRender(true);
again, from an action method in the controller.
in your controller ...
public function init() {
if ($this->getRequest()->isXmlHttpRequest()) {
// no Layout
$this->_helper->layout()->disableLayout();
// no views
$this->_helper->viewRenderer->setNoRender(true);
}
}
在你的控制器动作中,试试吧
$this->_helper->layout->disableLayout();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.