创建 xmlhttprequest 对象

2009-03-05 12:28:31 作者:Phil Ballard | 【

很多浏览器允许直接创建XMLHTTPRequest对象,此脚本演示了在不同情况下创建XMLHTTPRequest的方法,脚本会不断尝试各种方法创建,知道创建成功

创建xmlhttprequest对象的方法

try {
req = new XMLHttpRequest(); /* e.g. Firefox */
} catch(e) {
  try {
    req = new ActiveXObject(\"Msxml2.XMLHTTP\");  /* some versions IE */
  } catch (e) {
    try {
    req = new ActiveXObject("Microsoft.XMLHTTP");  /* some versions IE */
    } catch (E) {
      req = false;
    }
  }
}

相关资源