Saturday, 10 March 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

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...