i'm trying to read "local" files inside my directory with vanilla javascript inside a html. Since AJAX does not work because of CORS policy - can't read local files from a browser, I "outsmart" them using iframe which supplemented with json files that I want to read.
The problem is - I managed to get the iframe but don't know how to extract the "data" from this iframe.
Javascript:
fileframe = document.getElementById("jsonfile");
fileframe.setAttribute("src", "test.json");
console.log(fileframe);
Chrome console output
<iframe id="jsonfile" src="test.json" style="display:none">
#document
<html>
<head>
<meta name="color-scheme" content="light dark">
</head>
<body>
<pre style="word-wrap: break-word; white-space: pre-wrap;">{
"content": "thisisacontent"
}</pre>
</body>
</html>
</iframe>
The data i want to get is the {"content" : "thisisacontent"} a newbie programmer here, any help will be appreciated! thanks!!