0

为了提供 ajax 操作,我执行以下操作:

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

但响应带有以下错误:在路径中找不到脚本'async/tax.phtml' (/var/www/app/trunc/application/views/scripts/:./views/scripts/)

4

2 回答 2

0
  1. 您是否检查过该文件是否tax.phtml存在于/var/www/app/trunc/application/views/scripts/.
  2. 如果存在,则位于tax.phtml文件echo exit;底部。
于 2012-05-21T10:02:16.827 回答
0

为什么不使用 Ajaxcontext 操作助手?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')
}

然后将您的视图命名为“async/tax.ajax.phtml”并确保您的 ajax 调用请求 html 格式。

这样,您甚至可以调整您的代码以使用相同的控制器/操作自动响应 json、phtml 或 xml。

于 2012-05-21T10:46:35.107 回答