<html>
<body>
<h2>Fetch a JSON file with XMLHttpRequest</h2>
<p id="demo"></p>
<script>
const xmlhttp = new XMLHttpRequest();
xmlhttp.onload = function() {
const myObj = JSON.parse(this.responseText);
document.getElementById("demo").innerHTML = myObj.name;
}
xmlhttp.open("GET.html", "json_demo.txt");
xmlhttp.send();
</script>
</body>
<!-- Mirrored from www.w3schools.com/js/tryit.asp?filename=tryjson_ajax by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 21 Dec 2022 16:49:21 GMT -->
</html>