Aviv
Aviv

Reputation: 75

jQuery XHTML Compliance

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?

Upvotes: 2

Views: 925

Answers (1)

Alohci
Alohci

Reputation: 82966

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.

Upvotes: 1

Related Questions