在Ajax中我们用到XMLHttpRequest对象,对于不同浏览器之间是否对XMLHttpRequest对象同时兼容需要我们作出处理

Code
var xmlhttprequest = false;
function createXMLHttpRequest() {
try {
xmlhttprequest = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e1) {
try
{
xmlhttprequest=new ActiveXObject("Microsoft.XMLHTTP");
}
catch()
{
xmlhttprequest=false;
}
}
if(!xmlhttprequest && typeof XMLHttpRequest!='undefined')
{
xmlhttprequest=new XMLHttpRequest();
}
}