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();