tags: Ajax
, Web 2.0
, GUI
, HTML
, XML
, Web Development
posted: Thursday, April 20th, 2006
After further thought and consideration, I retract my statement that HTML should never be sent back to an AJAX request. There was a reason I made that statement, however I can’t fill you in on it yet (hint: I have to wait for a future software release). But, even with that reason, I have no issue with using HTML in an AJAX response. I wrongly applied a wise and fully correct architectural principle, which I will elaborate on in a future post, to the AJAX situation.
Hopefully at some point in the future, I can go into more detail on why I first wrongly concluded that this should never be done. Until then, rest assured, I will use whatever format fits the circumstance (JSON, HTML, XML).
Comments (3)
Leave a Comment
I would not use json because it’s not compatible with older versions of php.
Instead i generate the html(if any) in my ajax page.
why wouldn’t you do that ?
My preference to not respond to an AJAX request with HTML is because I prefer a more defined separation between data and markup, and because I like my data feeds to be reusable.
So, I prefer to make AJAX calls that result in XML in most cases. I can then parse the XML with Javascript or apply an XSL directly to it. That separates my formatting of the data from the data, and allows me to reuse that data feed in other circumstances, regardless of the styling of the data. If you include HTML around that data in the response you cannot use it again in a different situation.
RSS feed for comments on this post. TrackBack
[…] UPDATE: Ignore my reservations about HTML in AJAX responses and see my followup post: AJAX Returning HTML (change of opinion). […]