From 66987f335bb2be6707e0c9b3b30cd76357960472 Mon Sep 17 00:00:00 2001 From: hina latif Date: Mon, 25 Jan 2021 23:29:48 -0500 Subject: [PATCH 1/3] ajax 4 steps --- ajax-lab.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 ajax-lab.js diff --git a/ajax-lab.js b/ajax-lab.js new file mode 100644 index 0000000..b6fb282 --- /dev/null +++ b/ajax-lab.js @@ -0,0 +1,16 @@ +var xhr = new XMLHttpRequest(); +xhr.onreadystatechange = function () { + if (xhr.readyState === 4) { + var image = JSON.parse(xhr.responseText); + console.log(xhr.responseText); + document.getElementById('image1').src = image.message[0]; + document.getElementById('image2').src = image.message[1]; + document.getElementById('image3').src = image.message[2]; + } +}; +function sendAJAX() { +} +xhr.open('GET', 'https://dog.ceo/api/breeds/image/random/3'); + +xhr.send(); + From 983fba5b8d9e5a4ac5f372e822ae3c3cc71b20dd Mon Sep 17 00:00:00 2001 From: hina latif Date: Mon, 25 Jan 2021 23:30:37 -0500 Subject: [PATCH 2/3] ajax 4 steps --- ajax.html | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 ajax.html diff --git a/ajax.html b/ajax.html new file mode 100644 index 0000000..7a336c8 --- /dev/null +++ b/ajax.html @@ -0,0 +1,17 @@ + + + + + Document + + + + +
+ + + +
+ + + From f969114620b36e1ff1b84bcdf69d314ab518742d Mon Sep 17 00:00:00 2001 From: hina latif Date: Mon, 25 Jan 2021 23:40:46 -0500 Subject: [PATCH 3/3] fixed the order of 4 steps --- ajax-lab.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ajax-lab.js b/ajax-lab.js index b6fb282..cb608e8 100644 --- a/ajax-lab.js +++ b/ajax-lab.js @@ -9,8 +9,8 @@ xhr.onreadystatechange = function () { } }; function sendAJAX() { -} -xhr.open('GET', 'https://dog.ceo/api/breeds/image/random/3'); -xhr.send(); +xhr.open('GET', 'https://dog.ceo/api/breeds/image/random/3'); + xhr.send(); +}