//不同的浏览器使用不同的方法来创建 XMLHttpRequest 对象。
//Internet Explorer 使用 ActiveXObject。
//其他浏览器使用名为 XMLHttpRequest 的 JavaScript 内建对象。
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
在所有现代浏览器中(包括 IE 7):
xmlhttp=new XMLHttpRequest()
在 Internet Explorer 5 和 6 中:
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")