Diazo 将不需要的 html 标头添加到 json 响应中
我有一个空白的 Plone 4.1 站点,仅安装了collective.quickupload。上传 portlet 工作正常,直到我安装 plone.app.theming 并应用我的主题。文件仍在上传,但 Web 客户端处于“失败”状态。
检查服务器的 ajax 响应,我发现它们被 html 标头包裹。 旧响应(在安装 diazo 并应用我的主题之前)只是
{"success":true}
新响应(在安装 diazo 并应用我的主题之后)被 html 标签包裹:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><body><p>{"success":true}</p></body></html>
我已将我的rule.xml 文件粘贴到此处(没什么特别的,那里仅受 css 限制的一条规则:if-content="#visual-portal-wrapper"): http://pastebin.com/SaK13Fni
我应该怎么做才能解决这个问题?
谢谢
I have a blank Plone 4.1 site with only collective.quickupload installed. The upload portlet worked fine until I install plone.app.theming and apply my theme. The files were still uploaded, but the web client got "Failed" status.
Inspecting the ajax response from server I found that they were wrapped by html header.
The old response (before install diazo & apply my theme) was simply
{"success":true}
The new response (after install diazo and apply my theme) was being wrapped by a html tag:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><body><p>{"success":true}</p></body></html>
I've pasted my rule.xml file here (nothing special, there is only one rule conditioned by css:if-content="#visual-portal-wrapper"): http://pastebin.com/SaK13Fni
What should I do to work around this ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了避免这种行为,您必须在
rules.xml
中添加一个例外,指定不将您的主题应用于您的特定视图,如下所示:编辑:
我已经尝试过使用我的重氮主题之一和 json 视图,我没有遇到您的问题。所以我认为问题出在你的rules.xml 或你的json 视图中。您应该尝试以下两种方式之一:
以这种方式更改您的
rules.xml
:<前><代码> <规则
xmlns="http://namespaces.plone.org/diazo"
xmlns:css="http://namespaces.plone.org/diazo/css"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<规则 css:if-content="#visual-portal-wrapper">
<主题 href="index.html" />
您是否已经在中指定了输出的“内容类型”
你的 json 视图?像这样:
如果不是,这可能就是问题所在。
To avoid this behavior you have to add an exception in your
rules.xml
that specify to not apply your theme to your specific view , like this:edit:
I've tried with one of my diazo themes and a json view and I didn't have your issue. So I think the problem is either in your rules.xml or in your json view. You should try one of these two way:
change your
rules.xml
this way:have you already specified the "Content-type" of the output in
your json view? Like this:
If not, that's probably the problem.
小心使用 Chrome 检查器...当您检查它时,它会在您的 json 周围添加 html head 和 pre 标记...如果您查看视图:页面的源代码(老派),它实际上并不存在...
Watch out for using Chrome inspector... it adds the html head and pre tags around your json when you inspect it...it's not actually there if you look at view:source of the page (old school)...