Multiple changes

This commit is contained in:
2026-01-22 22:24:56 -05:00
parent 8711fbbbbb
commit b16f7a0757
20 changed files with 626 additions and 15 deletions
@@ -0,0 +1,50 @@
<html>
<head>
<title>ASynchronous AJAX</title>
</head>
<body onload="main();">
<script type="text/JavaScript">
let xmlHttp = new XMLHttpRequest();
function requestCallbackFunction(){
if(xmlHttp.status === 200){
writeToContent(xmlHttp.responseText);
let data = JSON.parse(xmlHttp.responseText);
console.log(data);
setTimeout(null, 1000);
data['someProperty'] = { data:"This is an additional value"};
console.log(JSON.stringify(data));
}
}
function getJSONASynchronous(url){
if(xmlHttp !== null){
xmlHttp.onload = requestCallbackFunction;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
}
function writeToContent(data){
document.getElementById("content").innerText = data;
}
function main(){
getJSONASynchronous("https://google.ca");
getJSONASynchronous("https://reqbin.com/echo/get/json");
getJSONASynchronous("./data.json");
}
</script>
<div id="content">
</div>
</body>
</html>
@@ -0,0 +1,40 @@
<html>
<head>
<title>Synchronous AJAX</title>
</head>
<body onload="main();">
<script type="text/JavaScript">
function getJSONSynchronous(url){
let response = "";
let xmlHttp = new XMLHttpRequest();
if(xmlHttp !== null){
xmlHttp.open("GET", url, false);
xmlHttp.send(null);
response = xmlHttp.responseText;
return response;
}
}
function writeToContent(data){
document.getElementById("content").innerText = data;
}
function main(){
writeToContent(getJSONSynchronous("https://google.ca"));
writeToContent(getJSONSynchronous("https://reqbin.com/echo/get/json"));
writeToContent(getJSONSynchronous("./data.json"));
}
</script>
<div id="content">
</div>
</body>
</html>