From ac75882980219a14f95a94dc9ce5d2b97130f5bb Mon Sep 17 00:00:00 2001 From: IamFotini <74632550+IamFotini@users.noreply.github.com> Date: Wed, 27 Jan 2021 20:06:04 -0500 Subject: [PATCH] lab completed --- index.html | 14 ++++++++++++++ main.js | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 index.html create mode 100644 main.js diff --git a/index.html b/index.html new file mode 100644 index 0000000..fbb66ed --- /dev/null +++ b/index.html @@ -0,0 +1,14 @@ + + + + + + Ajax Dog + + + random dog +
+ + + + diff --git a/main.js b/main.js new file mode 100644 index 0000000..aba0b71 --- /dev/null +++ b/main.js @@ -0,0 +1,16 @@ +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(); +//document.getElementById('load').style.display = "none"; \ No newline at end of file