From ad5093213063365bcb7202eac204f3492b13a960 Mon Sep 17 00:00:00 2001 From: James Nesmith Jr <72023286+JamesNesmithJr@users.noreply.github.com> Date: Thu, 28 Jan 2021 17:51:48 -0500 Subject: [PATCH] test commit --- index.html | 23 +++++++++++++++++++++++ script.js | 19 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 index.html create mode 100644 script.js diff --git a/index.html b/index.html new file mode 100644 index 0000000..12edd80 --- /dev/null +++ b/index.html @@ -0,0 +1,23 @@ + + + + + + Ajax Dog + + + + random dog + +
+ + + + + + + + + + + diff --git a/script.js b/script.js new file mode 100644 index 0000000..2cecb94 --- /dev/null +++ b/script.js @@ -0,0 +1,19 @@ +let xhr = new XMLHttpRequest(); +xhr.onreadystatechange = function() { + if (this.readyState === 4 && this.status === 200) { + let data = JSON.parse(this.responseText); + document.getElementById('dogimg').src = data.message; + console.log(data.message); + + } + +}; + function sendAJAX() { + xhr.open('GET', `https://dog.ceo/api/breeds/image/random`); + xhr.send(); + } + +xhr.open('GET', `https://dog.ceo/api/breeds/image/random`); + + +xhr.send();