//导入js文件
function getResult(url, ready) {
var xmlHttp;
var r = function() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
//alert(isIE);
var xmlstr;
var xmldoc;
var isIE = !!(window.attachEvent && !window.opera);
if (isIE)
xmldoc = xmlHttp.responseXML;
else {
xmlstr = xmlHttp.responseText;
alert(xmlstr);
var parser = new DOMParser();
xmldoc = parser.parseFromString(xmlstr, "text/xml");
}
try {
ready(xmldoc);
} catch (e) {
alert(e.message);
}
}
}
}
var create = function(url, r) {
try {
// Firefox, Opera 8.0+, Safari
xmlHttp = new XMLHttpRequest();
} catch (e) {
// Internet Explorer
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
alert("您的浏览器不支持AJAX!");
return false;
}
}
}
xmlHttp.onreadystatechange = r;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
create(url, r);
}
//应用
function ready(xmlDoc)
{
x=xmlDoc.getElementsByTagName("a")[1];
y=x.childNodes[0];
txt=y.nodeValue;
alert(txt);
}
getResult("../xml.jsp",ready);