在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
创建XMLHTTP对象,区别IE,Mozilla浏览器 复制代码 代码如下: function getRequest() { //获得Url 的responseText http_request = false; if (window.XMLHttpRequest) { //对于Mozilla﹑Netscape﹑Safari等浏览器,创建XMLHttpRequest http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { //如果服务器响应的header不是text/xml,可以调用其它方法修改该header http_request.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { // 对于Internet Explorer浏览器,创建XMLHttpRequest try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } return http_request; } 复制代码 代码如下: function getResponseText(url) //获得Url 的responseXML { http_request=getRequest(); http_request.open('GET', url, false); http_request.send(null); if (http_request.readyState == 4) { // 收到完整的服务器响应 if (http_request.status == 200) { //HTTP服务器响应的值OK requestdoc = http_request.responseText; //将服务器返回的字符串写到页面中ID为message的区域 } else { requestdoc = http_request.status; } } return requestdoc; } 复制代码 代码如下: function getResponseText(url) { http_request=getRequest(); http_request.open('GET', url, false); http_request.send(null); if (http_request.readyState == 4) { // 收到完整的服务器响应 if (http_request.status == 200) { //HTTP服务器响应的值OK requestdoc = http_request.responseXML; //将服务器返回的字符串写到页面中ID为message的区域 } else { requestdoc = http_request.status; } } return requestdoc; } |
请发表评论