Zend Framework将JSON返回给没有Doctype HTML的ajax GET请求

时间:2013-10-06 11:17:52

标签: json jquery zend-framework

我试图通过GET在特定的Action上将JSON对象返回给AJAX请求。

这是我通过GET-Request触发的行动:

    $this->_helper->viewRenderer->setNoRender(true);
    $this->_helper->layout()->disableLayout(); 
    $Mapper = new Application_Model_Mapper();
    $result = $Mapper->findById($this->getRequest()->getParam('id'));

   echo $this->_helper->json($result);

回应如下:

<!DOCTYPE HTML> 

[{"foo":"bar", ... }]

通过Doctype标记,我无法正确处理JSON数据,因为它未被识别为JSON对象。

我尝试删除Doctype标记但没有渲染视图并禁用Action中的布局,但它仍然存在。是否有任何关于从响应中正确删除它们的想法?

0 个答案:

没有答案