first of all, yes I did search the community for any solutions, but I just dont understand them :(
So I have a JavaScript Function which reads my .json file and shows the specific object I need in VisualCodee console. Now Im trying to display the Object into a HTML file.
Basically: How do I display the client_ip in a HTML file?
Down below you can see my JavaScript function which reads the client_ip in my .json file.
var obj = {
"source": "/var/log/apache2/git.1234.de-443-access.json",
"data": {
"http_code": 204,
"pid": "-",
"request_id": "-",
"log_level": "-",
"body_size": 0,
"host": "git.1234.de",
"peer_ip": "10.200.13.212",
"duration": 1693,
"source": "-",
"client_port": "-",
"error_message": "-",
"client_ip": "10.200.13.333",
}
}
//for client_ip ,
var client_ip = obj.data.client_ip;
console.log(obj.data.client_ip)
Here you can see my HTML, the name of my .json file which im reading from is "ws.json" and the name of my javascript file is "kommschon.js".
<script type="text/javascript">
kommschon.js();
function kommschon.js(){
document.getElementById('clientIp).innerHTML ='clientIP';
};
</script>
<body>
<h1>Java Loop</h1>
<button type="button" class="button1" onclick="alert('Cleared!')">Clear!</button>
<button class="button2" onclick="alert('Function running!')">Run!</button>
<div id="clientIp">
</div>