diff --git a/dog-jq.html b/dog-jq.html new file mode 100644 index 0000000..7476a8f --- /dev/null +++ b/dog-jq.html @@ -0,0 +1,16 @@ + + + + + + + + Document + + + +
+ +
+ + \ No newline at end of file diff --git a/dog-jq.js b/dog-jq.js new file mode 100644 index 0000000..eea6ea1 --- /dev/null +++ b/dog-jq.js @@ -0,0 +1,12 @@ +//completed using jquery +$(document).ready(function(){ + $('#buttonclick').on('click','button',function(){ + $.ajax('https://dog.ceo/api/breeds/image/random/3',{ + success: function(response){ + for (let i=0; i<3; i++) { + $('#buttonclick').append(``) + } + } + }) + }) +}); \ No newline at end of file diff --git a/dog.html b/dog.html new file mode 100644 index 0000000..da188e6 --- /dev/null +++ b/dog.html @@ -0,0 +1,11 @@ + + + + Random Dogs + + + +
+
+ + \ No newline at end of file diff --git a/dog.js b/dog.js new file mode 100644 index 0000000..7f606d8 --- /dev/null +++ b/dog.js @@ -0,0 +1,23 @@ +//completed using vanilla js +function createImg() { + const xhr = new XMLHttpRequest(); + xhr.onreadystatechange = () => { + if (xhr.readyState === 4) { + const response = JSON.parse(xhr.responseText); + let img; + for (let i=0; i<3; i++) { + img = ``; + document.getElementById('dog-div').innerHTML = img + document.getElementById('dog-div').innerHTML; + } + } + console.log(xhr); + console.log(response.message); + }; + + xhr.open('GET', 'https://dog.ceo/api/breeds/image/random/3'); + xhr.send(); +} + +function sendAJAX() { + createImg(); +} \ No newline at end of file