diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..7a9dfa0 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "pwa-chrome", + "request": "launch", + "name": "Launch Chrome against localhost", + "url": "http://localhost:8080", + "webRoot": "${workspaceFolder}" + } + ] +} \ No newline at end of file diff --git a/Ajax.html b/Ajax.html new file mode 100644 index 0000000..50af8e8 --- /dev/null +++ b/Ajax.html @@ -0,0 +1,14 @@ + + + + + + + + +
+ +
+ + + \ No newline at end of file diff --git a/Ajax.js b/Ajax.js new file mode 100644 index 0000000..a7dcafc --- /dev/null +++ b/Ajax.js @@ -0,0 +1,19 @@ + +let xhr = new XMLHttpRequest +xhr.onreadystatechange= function(){ + if (xhr.readyState=== 4 && xhr.status ===200){ + let data =JSON.parse(xhr.responseText); + let image; + for(let i=0;i<3;i++){ + image =``; //accessing each index in the message array of the json file + document.getElementById("ajax").innerHTML += image; //concatenating so that each old image is not replaced by the new image + // same as saying: + //document.getElementById("ajax").innerHTML = `` + } + } +} +xhr.open ("GET","https://dog.ceo/api/breeds/image/random/3"); +function fetch(){ + +xhr.send(); +} \ No newline at end of file