我的代码如下所示:
function fetchgraphdata()
{
var xmlhttp_1;
var urls = "xml_gen_graph.jsp";
console.log("Url Formed = " + urls);
if (window.XMLHttpRequest) {
xmlhttp_1 = new XMLHttpRequest();
}
else {
xmlhttp_1 = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp_1.open("POST",urls, true);
xmlhttp_1.send();
xmlDoc = xmlhttp_1.responseXML;
xmlhttp_1.onreadystatechange = function ()
{
if (xmlhttp_1.readyState === 4)
{
console.log("Graph data is ready");
z = 0;
xmlDoc = xmlhttp_1.responseXML; // xmlhttp_1.responseXML.childNodes;
x = xmlDoc.getElementsByTagName("day");
y = xmlDoc.getElementsByTagName("consp");
while (xmlDoc !== null)
{
date_1 = x[z].childNodes[0].nodeValue;
consp_1 = y[z].childNodes[0].nodeValue;
console.log("date = " + date_1 + " Consumption = " + consp_1);
z++;
}
}
};
}

问题:
xmlhttp_1.status
- > return
- > undefined
Uncaught TypeError: Cannot read property getElementsByTagName
为null。有人可以帮助我吗?
Lorem ipsum dolor sit amet,consectetur adipiscing elit,sed do eiusmod tempor incididunt ut labore et dolore magna aliqua。