# AJAX and non-xml entities

**URL:** <https://www.ruby-forum.com/t/ajax-and-non-xml-entities/91626>\
**Category:** Rails\
**Created:** [April 10, 2007, 11:20pm UTC](https://www.ruby-forum.com/t/ajax-and-non-xml-entities/91626 "2007-04-10T23:20:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 10, 2007, 11:20pm UTC](https://www.ruby-forum.com/t/ajax-and-non-xml-entities/91626/1 "2007-04-10T23:20:23Z")

</div>

Recently I made some changes so that I am serving up XHTML 1.1. I’m  
talking about real XHTML where the mime type is changed to application/  
xhtml+xml and firefox raises hell when there are errors rather then  
trying to work around it.

I have a page that uses AJAX to update a div in the page, and I ran  
into a problem that I didn’t have when serving using the text/html  
mime type. The content that was passed back from the AJAX request  
contained the “nbsp” html entity and firefox raised an error saying  
that “nbsp” is not a valid xml entity.

So my question is how many other html entities are not valid when  
passed as xml, and how do I properly send AJAXed content that contains  
any such entity?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 10, 2007, 11:30pm UTC](https://www.ruby-forum.com/t/ajax-and-non-xml-entities/91626/2 "2007-04-10T23:30:23Z")

</div>

I forgot to ask, is there anyway have the server include a dtd or  
xmlns tag within the xml response to AJAX requests so that this  
doesn’t cause problems? If not, shouldn’t rails be automatically  
converting entities like this to something that is xml compatable like  
“& # 1 6 0 ;”

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 10, 2007, 11:55pm UTC](https://www.ruby-forum.com/t/ajax-and-non-xml-entities/91626/3 "2007-04-10T23:55:25Z")

</div>

2007/4/11, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

\<…\> So my question is how many other html entities are not valid when

> passed as xml, and how do I properly send AJAXed content that contains  
> any such entity?

I will not count how many are not valid, but only these firve are safe:  
& ' \< \> "

## Regards, Rimantas

[http://rimantas.com/](http://rimantas.com/)
