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