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
- Wine Tasting in Napa Valley
- How to build a Shot-Ski
- Bus Project Update
- Farewell to the 2011-2012 Ski Season
- Cruising around the Western Caribbean
- Spring Break!
- A Spectacular Trip to Stockholm and Madrid
- Comparing Web Frameworks and HTML5 with Play Scala at Jfokus 2012
- Play Framework 2.0 with Peter Hilton at Jfokus
- Secure JSON Services with Play Scala and SecureSocial
Posted by James Strachan on December 12, 2004 at 02: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 05:56 PM MST #
Posted by Will on December 12, 2004 at 08:48 PM MST #
Posted by Dan Allen on December 13, 2004 at 07:28 AM MST #
Posted by Dan Allen on December 13, 2004 at 07:29 AM MST #
Posted by Dan Allen on December 13, 2004 at 07:43 AM MST #
Posted by barry.b on December 13, 2004 at 09:55 AM MST #
http://www.theserverside.com/news/thread.tss?thread_id=30520
Posted by Alexandre Jacques on December 13, 2004 at 01:45 PM MST #
Posted by Eu Gene Lim on December 14, 2004 at 07:54 PM MST #
Posted by Matt Raible on December 14, 2004 at 10:40 PM MST #
Posted by Greg on December 19, 2004 at 02:08 AM MST #
Posted by Harold Neiper on December 22, 2004 at 12:48 PM 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 03:07 AM MST #