Saturday December 11, 2004
XmlHttpRequest
Dave quotes it, Charles writes it. XmlHttpRequest is the topic at hand and how it will help us build the next generation of web UIs. I've used Brent Ashley's JSRS Library to do some fancy UI work (one drop-down populates another) last year. It worked well in combination with Erik Hatcher's articles: Remote scripting using a servlet and Sending rich messages between client and server using asynchronous messaging. The project was AppFuse based, so I have the code if someone really wants it.
An example of XmlHttpRequest is in Roller itself - in the twisty comments you see on this site. For those who have used them, you probably know they're somewhat buggy. With all this talk of XmlHttpRequest, maybe it's high-time to revisit Roller's implemenentation and see if the technology has gotten any better. In reality, I know it hasn't - it's the browsers that are the problem and there hasn't been an update to IE in quite some time. My code could probably use some work though. If you want to dig in and check it out, here's the xmlextras.js that does the heavy lifting and comment-specific JavaScript.
After looking at this code this morning, it looks like there's different methods being used for the different browsers.
/////////////////////////////////////////////////////////////////////
//// XML Document loading
function loadXMLDocument(aURL, aCallback)
{
gMediaCallback = aCallback;
if (window.ActiveXObject) {
// Internet Explorer XML loading syntax
gMediaDoc = new ActiveXObject(getControlPrefix() + ".XmlDom");
gMediaDoc.onreadystatechange = onMediaReadyStateChange;
gMediaDoc.async = true;
gMediaDoc.load(aURL);
} else {
// Mozilla XML loading syntax
gMediaDoc = document.implementation.createDocument("", "", null);
var xmlHttp = new XMLHttpRequest();
xmlHttp.overrideMimeType("text/xml");
xmlHttp.open("GET", aURL, false);
xmlHttp.send(null);
gMediaDoc.loadXML(xmlHttp.responseXML.xml);
onMediaLoaded();
}
}
I wonder if there's a common way that can be used for both browsers? BTW, 99% of the code for these comments was borrowed from Joe Hewitt.
Later: Another article covering this technology: Using the XML HTTP Request object. Hat tip to Carl.
Posted in Roller
at Dec 11 2004, 09:29:09 AM MST
13 Comments
Search This Site
Recent Entries
- What's wrong with JSF
- Why such a busy week?
- New Passport in 9 Days
- EhCache Project Busy this Summer
- Spontaneous Stuff Weekend
- Awesome Birthday Present: A Kegerator
- Maven Plugin for Running Integration Tests against Multiple Containers
- Presenting Web Frameworks of the Future Tomorrow in Denver
- My OSCON Aftermath
- OSCON 2008 Wrapup
Posted by James Strachan on December 12, 2004 at 01:08 AM MST #
Matt, it occurs to me that dynamically populating drop-downs could be very common use for this technology; See <a href="http://www.jlamp.com/blog/2004/12/12/1102893719000.html ">this blog entry on my site.
Also, here's another useful article which has more info on Safari.
Posted by Will on December 12, 2004 at 04:56 PM MST #
Posted by Will on December 12, 2004 at 07:48 PM MST #
Posted by Dan Allen on December 13, 2004 at 06:28 AM MST #
Posted by Dan Allen on December 13, 2004 at 06:29 AM MST #
Posted by Dan Allen on December 13, 2004 at 06:43 AM MST #
Posted by barry.b on December 13, 2004 at 08:55 AM MST #
http://www.theserverside.com/news/thread.tss?thread_id=30520
Posted by Alexandre Jacques on December 13, 2004 at 12:45 PM MST #
Posted by Eu Gene Lim on December 14, 2004 at 06:54 PM MST #
Posted by Matt Raible on December 14, 2004 at 09:40 PM MST #
Posted by Greg on December 19, 2004 at 01:08 AM MST #
Posted by Harold Neiper on December 22, 2004 at 11:48 AM MST #
heres my code:
function getXMLHTTP(){ var A = null; try{ A = new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ try{ A = new ActiveXObject("Microsoft.XMLHTTP"); } catch(oc){ A = null; } } if(!A && typeof XMLHttpRequest != "undefined") { A = new XMLHttpRequest(); } return A; }Posted by Glenn on March 07, 2007 at 02:07 AM MST #