From e44fc3530c6ee368ca2cac856d34bdfd3e56ed80 Mon Sep 17 00:00:00 2001 From: Bluhotsauce Date: Tue, 26 Jan 2021 21:17:02 -0500 Subject: [PATCH 1/2] AJAX Activity --- index.html | 17 +++++++++++++++++ main.js | 18 ++++++++++++++++++ style.css | 0 3 files changed, 35 insertions(+) create mode 100644 index.html create mode 100644 main.js create mode 100644 style.css diff --git a/index.html b/index.html new file mode 100644 index 0000000..2a0b648 --- /dev/null +++ b/index.html @@ -0,0 +1,17 @@ + + + + + + AJAX DOG + + + random dogs +
+ + + + + + + \ No newline at end of file diff --git a/main.js b/main.js new file mode 100644 index 0000000..cb4f759 --- /dev/null +++ b/main.js @@ -0,0 +1,18 @@ +let xhr = new XMLHttpRequest(); +xhr.onreadystatechange = function () { + if (this.readyState === 4 && this.status === 200) { + let data = JSON.parse(this.responseText); + document.getElementById('dog image').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"; diff --git a/style.css b/style.css new file mode 100644 index 0000000..e69de29 From e00a182e1f483990450d664d234a0795a4a9c8b3 Mon Sep 17 00:00:00 2001 From: Bluhotsauce Date: Thu, 28 Jan 2021 21:05:37 -0500 Subject: [PATCH 2/2] added 3 images --- index.html | 2 ++ main.js | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 2a0b648..dbb7bf8 100644 --- a/index.html +++ b/index.html @@ -7,6 +7,8 @@ random dogs + random dogs + random dogs
diff --git a/main.js b/main.js index cb4f759..b6c51cd 100644 --- a/main.js +++ b/main.js @@ -2,13 +2,15 @@ let xhr = new XMLHttpRequest(); xhr.onreadystatechange = function () { if (this.readyState === 4 && this.status === 200) { let data = JSON.parse(this.responseText); - document.getElementById('dog image').src = data.message; + document.getElementById('dog image').src = data.message[0]; + document.getElementById('dog image1').src = data.message[1]; + document.getElementById('dog image2').src = data.message[2]; console.log(data.message); } }; function sendAJAX() { - xhr.open ('GET', `https://dog.ceo/api/breeds/image/random`); + xhr.open ('GET', `https://dog.ceo/api/breeds/image/random/3`); xhr.send(); }