日期:2014-05-16 浏览次数:20664 次
// JavaScript Document function cLaw(id) { title = document.getElementById(id).innerText; // alert("test:"+title); url = ("/yjOutGate/Policy?title=" + title); cLawRequest(url); } // 浏览器判断 function xhttp() { var http_request = null; if (window.XMLHttpRequest) { http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { http_request.overrideMimeType("text/xml"); } } else if (window.ActiveXObject) { try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { } } } if (!http_request) { alert("初始化XMLHttpRequest对象失败"); return false; } return http_request; } var http_law = xhttp(); function cLawRequest(url) { http_law.onreadystatechange = alertC_Law; http_law.open("GET", url, true); // alert(url); http_law.send(null); } function alertC_Law() { if (http_law.readyState == 4) { if (http_law.status == 200) { var info = http_law.responseText; var infojson = eval("(" + info + ")"); alert(info);// 这里就获取不到需要的数据了! } else { alert('请与工作人员联系或者检查您的网络'); } } }
------解决方案--------------------
一个是注释掉var infojson = eval("("+info+")");
二是在function cLawRequest(url) {
http_law .onreadystatechange = alertC_Law;
http_law .open("GET",url, true);
//alert(url);
http_law .send(null);
}
改成
function cLawRequest() {
var url="Default.aspx"; http_law .onreadystatechange = alertC_Law;
http_law .open("GET",url, true);
//alert(url);
http_law .send(null);
}
我没有你的那个url值,不知道你的是否写错了?????
其他没变