以下のコードを実行すると、childnodes undefined エラーが発生します。私は何を間違っていますか?また、これを実現するためのより良い方法はありますか?
var xmlhttp;
if (window.XMLHttpRequest)
{// code fop=new XMLHr IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
//document.getElementById("myDiv").innerHTML += xmlhttp.responseText;
if (window.DOMParser)
{
parser=new DOMParser();
xmlDoc=parser.parseFromString(xmlhttp.responseText,"text/xml");
var x=xmlDoc.getElementsByTagName("STATUS");
if(x[0].childNodes[0].wholeText == "notLoggedIn")
{
window.location='login.html';
}