diff --git a/ajax.html b/ajax.html new file mode 100644 index 0000000..3f79883 --- /dev/null +++ b/ajax.html @@ -0,0 +1,17 @@ + + + + + + Dog API + + +
+ + + + +
+ + + \ No newline at end of file diff --git a/ajax.js b/ajax.js new file mode 100644 index 0000000..d689ac9 --- /dev/null +++ b/ajax.js @@ -0,0 +1,22 @@ + + + + +let xhr = new XMLHttpRequest +xhr.onreadystatechange = function (){ +if (this.readyState === 4 && this.status === 200){ + + let data =JSON.parse(this.response) + console.log(data) + document.getElementById("image1").src = data.message[0] + document.getElementById("image2").src = data.message[1] + document.getElementById("image3").src = data.message[2] + + + } +} +let fetch = function(){ +xhr.open('GET', 'https://dog.ceo/api/breeds/image/random/3', true); +xhr.send(); + +}