Title: JSON SCRIPT
Course: Fall 2023 - WEBD 164 (41934)

 | <!DOCTYPE html>
 | <html>
 | <body>
 | <h2>The XMLHttpRequest Object</h2>
 | <p id="demo">Let AJAX change this text.</p>
 | <button type="button" onclick="loadDoc()">Change Content</button>
 | <script>
 | function loadDoc() {
 | var xhttp = new XMLHttpRequest();
 | xhttp.onreadystatechange = function() {
 | if (this.readyState == 4 && this.status == 200) {
 | var content = JSON.parse(this.responseText);
 | for (x in content){
 | for (y in content[x]){
 | console.log(y + ':' + content[x][y]);
 | }
 | }
 | }
 | };
 | xhttp.open("GET", "https://jsonplaceholder.typicode.com/posts/", true);
 | xhttp.send();
 | }
 | </script>
 | </body>
 | </html>