获取XMLHttpRequest 的三种方式

来源:互联网 发布:杭州淘宝卖家都在哪 编辑:程序博客网 时间:2024/06/06 13:18

获取XmlHttpRequest对象

//1function getXMLHttpRequest() {var xmlHttpReq;try { // Firefox, Opera 8.0+, SafarixmlHttpReq = new XMLHttpRequest();} catch (e) {try {// Internet ExplorerxmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {try {xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");} catch (e) {}}}return xmlHttpReq;}//2function getXMLHttpRequest() {var xmlHttpReq = null;if (window.ActiveXObject) {// Internet ExplorerxmlHttpReq = new ActiveXObject("MSXML2.XMLHTTP.3.0");} else if (window.XMLHttpRequest) {xmlHttpReq = new XMLHttpRequest();}return xmlHttpReq;}//3function getXMLHttpRequest() {var xmlHttpReq = null;if (window.XMLHttpRequest) {// Mozilla Firefox, Opera 8.0+, SafarixmlHttpReq = new XMLHttpRequest();} else {if (window.ActiveXObject) {// Internet Explorertry {xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");} catch (e) {try {// Internet ExplorerxmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {}}}}return xmlHttpReq;}



0 0