Saturday, March 10, 2018

javascript - Cannot set property 'innerHTML' of null?

Why do I get an error or " Uncaught type error: Cannot set property 'innerHTML' of null?".
This is my code



function ajax()
{
var pathxml;
var answer;
if (window.XMLHttpRequest) {
pathxml = new XMLHttpRequest();

}
else
{
pathxml = new ActiveXObject("Microsoft.XMLHTTP");
}

pathxml.onreadystatechange= function()
{
if (pathxml.readyState==4 && pathxml.status==200)
{

answer = pathxml.responseText;

document.getElementById("ans").innerHTML = answer;

}
}
pathxml.open("GET","books/ax",true);
pathxml.send();
}

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...