[thelist] AJAX: Getting External Content by DIV?

Ben Glassman bglassman at gmail.com
Thu May 31 15:20:48 CDT 2007


When you fetch a document that is valid XML (in this case an XHTML file)
using Ajax you can access its XML tree via responsexml. You can then
traverse its DOM using the Javascript DOM methods (getElementsByTagName,
getElementById, etc.). From there you can generate whatever HTML you need
via createElement, createTextNode, etc. and append it to your document.

The book Bulletproof Ajax[1] by Jeremy Keith is a great introduction to Ajax
and includes coverage of how to do something like this. He has an example
where he is pulling contact information from an xml file, using it to create
html and inserting that into his document similarly to what you want to do.

[1] http://bulletproofajax.com/
[2] http://bulletproofajax.com/code/chapter04/xml/people/index.html

More information about the thelist mailing list