var xmlhttp;

try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");    // trying Internet Explorer 
}
catch(e)    // failed 
{
  xmlhttp = new XMLHttpRequest()
}
