<!DOCTYPE html>
<html>
<body>
<h2>XMLHttpRequestでJSONファイルを取得する</h2>
<p>JSON配列として書き込まれたコンテンツはJavaScript配列に変換されます。</p>
<p id="demo"></p>
<script>
const xmlhttp = new XMLHttpRequest();
xmlhttp.onload = function() {
const myArr = JSON.parse(this.responseText);
document.getElementById("demo").innerHTML = myArr[0];
}
xmlhttp.open("GET", "json_demo_array.txt", true);
xmlhttp.send();
</script>
</body>
</html>