doue8385 2012-05-21 09:52
浏览 39
已采纳

ZF:禁用动作助手viewRenderer

In order to provide an ajax action I do the following:

    public function preDispatch()
    {
        if ($this->getRequest()->isXmlHttpRequest()) {
                Zend_Controller_Action_HelperBroker::removeHelper('viewRenderer');
                Zend_Layout::getMvcInstance()->disableLayout();
        }           
    }

but the response comes with the following error: script 'async/tax.phtml' not found in path (/var/www/app/trunc/application/views/scripts/:./views/scripts/)

  • 写回答

2条回答 默认 最新

  • dsgrs26202 2012-05-21 10:46
    关注

    Why not using the Ajaxcontext action helper ? http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.contextswitch

    // supposedly in your async controller
    public function init() {
    $ajaxContext = $this->_helper->getHelper('AjaxContext');
    $ajaxContext->addActionContext('tax', 'html')
    }
    

    Then name your view "async/tax.ajax.phtml" and ensure that your ajax call ask for the html format.

    That way you can even adapt your code to automatically respond with json, phtml or xml with the same controller/action.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计