I finally surrendered and started using JSON. And I used the Javascript Fetch command for the first time. It works very well if you want to display JSON data inside the console.log. But if you want to display the data inside a HTML textbox, beware. You either get undefined data or Object Object. I know that there is some kind of async await command combination. But that creates a new problem. I get an error stating something about esversion 8. I tried to look up this information but I guess no one works with super easy web projects. So that was no help. Here is my current code:
JSON_Example.html
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>First JSON Experiment</title>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/exist/rest/db/apps/HTML_Student/JSON_Example.css"/>
<script language="javascript" src="http://localhost:8080/exist/rest/db/apps/HTML_Student/JSON_Example.js"/>
</head>
<body onload = "Setup()">
<input type = "text" id = "JSON_Text">
</input>
</body>
</html>
JSON_)Example.css
#JSON_Text {
position: absolute;
top: 200px;
left: 300px;
height: 25px;
width: 300px;
}
JSON_Example.js
function Setup() {
var XMLHttp;
var JSON_Data;
var JSON_Output;
var URL;
URL = 'http://localhost:8080/exist/rest/db/apps/HTML_Student/people.json';
fetch(URL)
.then(res => res.json())
.then(data => {JSON_Data = data})
.then(() => {console.log(JSON_Data);
document.getElementById("JSON_Text").value = JSON_Data;
});
}
People.json
{"name":"John", "age":30, "city":"New York"}