我正在使用ajax uploader 和Zend框架。
问题是当我对onSubmit使用json响应时。
使用$this->getHelper('Json')->sendJson($data);
我只得到一个saveas对话框。
问题是上传者希望每个响应都是“text / html”,但是json帮助器将“application / json”作为mimetype发送。
通常的反应一切正常,但我需要将一些信息发回给剧本。
那么我怎么能说Zend它应该用mimetype“text / html”发送jsondata?
答案 0 :(得分:3)
您可以使用response object影响回复。在你的控制器内:
$content = Zend_Json::encode(array('Foo' => 'Nice', 'Bar' => 'Vice'));
$this->getResponse()
->setHeader('Content-Type', 'text/html')
->setBody($content)
->sendResponse();
exit();
答案 1 :(得分:1)
另一种变体
echo Zend_Json::encode(array('result' => true));
exit;