Tuesday, February 28th, 2006

XML Responses and AJAX

Category: Programming, XmlHttpRequest

<p> DevArticles has posted a new tutorial to follow their previous item working with Ajax messages and responses with help from an ActiveX object. This time, they focus on the responseXML return value from the Ajax call.

If the response is XML, the responseXML represents the value derived via DOM object parsing. The reader should review the properties and methods discussed in my previous tutorials on AJAX and XMLDOM, so that reading this one will be easier. JavaScript works easily with the XMLDOM object. In this tutorial we will be accessing an XML document via AJAX.

Just like in the previous tutorial, they create the object they’ll use to work with the XML right at the start. They then take a second to look at the innerHTML attribute, showing what it is and how it can be used. They follow with an example XML response, the code to pull it over with Ajax, and how the object can be used to parse this result into something useful. They even include a detailed description of how to parse the XML document’s contents (versus just throwing the code out there and saying “this is the end result”).

Related Content:

  • Ajax Learning Guide
    Are you a Web developer? The time has come to rethink your entire approach to developing Web applications. Find out about the Ajax approach...
  • Ajax Learning Guide
    Are you a Web developer? The time has come to rethink your entire approach to developing Web applications. Find out about the Ajax approach...
  • Ajax Learning Guide
    Are you a Web developer? The time has come to rethink your entire approach to developing Web applications. Find out about the Ajax approach...
  • Sun joins Ajax Alliance
    Sun Microsystems has joined the OpenAjax Alliance, the industry body set up to promote use of the open source Ajax web development...
  • Choosing an Ajax framework
    Your customers won't have to fear Ajax if they have the right tools to work with. Help them determine which Ajax-specific framework, library or...

Posted by Chris Cornutt at 7:43 am
5 Comments

+++--
3.6 rating from 30 votes

5 Comments »

Comments feed TrackBack URI

I’m becoming more and more convinced that there should be some sort of credentials required before someone can post a tutorial about any topic–but specifically “hot” topics like this. I almost puked when I saw some of the code. Give you a hint folks: what’s wrong with this picture?
...
document.getElementById("x1").innerHTML= xhr.responseXML.

…forgetting about the extraneous period at the end of the comment (of course).
There’s quite a few little lovely bits like this. I particularly liked the way he used innerHTML and then document.write in the same function. If anything, this is a great example of how not to write JS, and for a community site to actually check an article by someone who knows before publishing it.

Comment by Tom Trenka — February 28, 2006

By the way, no offense but I’d suggest that you actually make sure the article in question isn’t questionable before posting about it. It’s one thing to be talking about new apps and what not, it’s something else when you point people at a resource that will spawn all sorts of misunderstanding and bad practices in code.

Comment by Tom Trenka — February 28, 2006

I particularly liked the way he used innerHTML and then document.write in the same function.

Comment by שש בש באינטרנט — July 17, 2006

are particularly liked the way he used innerHTML and then document.write in the same function thing.

Comment by שש בש באינטרנט — July 17, 2006

But the html is not the only way

Comment by שש בש באינטרנט — July 17, 2006

Leave a comment

You must be logged in to post a comment.