jQuery XHTML Compliance

橙三吉。 提交于 2019-12-11 03:17:09

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/7045253/jquery-xhtml-compliance

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!