jQuery XHTML合规性 [英] jQuery XHTML Compliance

查看:84
本文介绍了jQuery XHTML合规性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有点困惑。我在我的服务器上将内容类型切换到application / xhtml + xml,因为我正在使用XHTML +一些额外的属性(使用<!ATTLIST> 设置)。自从我这样做以来,一切都崩溃了。

例如,我有一个自动完成框,可以从我的服务器加载数据。发出AJAX请求时服务器的响应是application / json content-type。当后者包含一个&符时,我的浏览器会喊指定了无效或非法的字符串code:12 。当我将页面的内容类型恢复为text / html时,根本没有错误。我知道XHTML中的&符号与HTML中的符号不​​同,但响应的内容类型是application / json,那么为什么jQuery会尝试将其解析为xhtml?

我有其他类似的我的代码中的错误(所有jQuery / javascript相关)。

I am a little confused. I switched my content-type over to application/xhtml+xml on my server because I am using XHTML + some extra attributes (set with <!ATTLIST>). Since I did this, all hell broke loose.
For example, I have an autocomplete box that loads data from my server. The response from the server when an AJAX request is made is of application/json content-type. When the latter contains an ampersand in it, my browser shouts An invalid or illegal string was specified" code: "12. When I restore the content-type of my page to text/html, no error at all. I understand that an ampersand is represented differently in XHTML than it is in HTML, but the content type of the response is application/json, so why is jQuery trying to parse it as xhtml?
I have other similar errors throughout my code (all jQuery / javascript related).

我需要做些什么来避免这些错误?

What do I need to do to avoid these errors?

推荐答案

可能jquery使用作为JSON发送的数据并使用innerHTML之类的东西注入DOM。作为XML的页面要求innerHTML提供的数据也必须符合XML。

Possibly jquery is using the data sent as JSON and injecting in into the DOM using something like innerHTML. A page served as XML requires that the data supplied by innerHTML must also be XML conforming.

这篇关于jQuery XHTML合规性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆