Thursday, January 27, 2005

Further adventures in the land of XMLHttpRequest

This is probably the most butiful way to create a cross browser xmlHTTP object.


var xmlhttp = false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}

if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}

xmlhttp.open("GET", "test.xml",true);
xmlhttp.send(null);

0 Comments:

Post a Comment

<< Home