Archive for December 18, 2004
XMLHTTP
0Wow! I didn’t know that the XMLHttp object I’ve wrote a fairly involved HTML based, data enabled grid with client side data updates and all sorts of nifty things. As the day job is IE specific, I made use of Microsoft’s powerful and well designed XMLHTTP Active X control to make calls to server side code to do the data accesses. (as an aside, I did it in a pretty secure and very generic way, and I’m rather proud of it) Recently I saw Google’s new “beta” feature, Google Suggest and said to myself “Self, how the hell are they doing that. It feels like they are making server side data calls of some kind, and the only way I know to do that is with XMLHTTP. But, self, I’m using Safari right now and it is working fine.” This morning, as I’m trying to wake up and get ready for Molly’s graduation (CONGRATUALTIONS!! WOO!!) I saw an article on Slashdot where some helpful and ingenious soul dissected the Javascript for Google Suggest. I raced to click on the link and read with delight. (yes clever code is delightful to me) At the bottom, I saw a function that brought much intrigue:
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
}
So I said to myself “Self, lookie, they are making a call to XMLHttpRequest(). What is THAT? Is that a browser independent XMLHTTP? Could it be?” I opened a new Google window and searched on it. I found this. Thanks Apple for a clean and well written bit of documentation. And for Xcode. And for OS X. Oops, sorry. I guess I lost my train of thought. I’m pleased that the Safari and Mozilla developers opted to duplicate the interface exactly, even though it was Microsoft’s. It is clean and it works. At least I think so anyway. I can’t wait to play with this! It will be fun to tweak my grid to be browser independent.