AJAX を使用して Web サイトを更新しようとしています。
私のhtmlでは、とを使用しまし
span id="test1"
たspan id="test2"
。
ただし、test1のコンテンツのみが表示され、XML ファイルのtest2のコンテンツは表示されません。以下の私のjavascriptで何が間違っているのか誰か教えてもらえますか?
window.onload = function ShowAlert() {
if(window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET", "note.xml", false);
xmlhttp.send();
xmlDoc = xmlhttp.responseXML;
document.getElementById("test1").innerHTML = xmlDoc.getElementsByTagName("test1")[0].childNodes[0].nodeValue;
document.getElementById("test2").innerHTML = xmlDoc.getElementsByTagName("test2")[0].childNodes[0].nodeValue;
}