Hello folks!
I apologize in advance if this is posted in the wrong category or if there’s a more appropriate one for my issue.
I am currently facing a challenge with fetching values from a JSON file in an HTML document. It works as expected in SketchUp 2024, but not in earlier versions like SketchUp 2023 or SketchUp 2017.
Here’s the content of my HTML file:
<!DOCTYPE html>
<html>
<body>
<div>
<span class="extName">If you read this, it's not working</span>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
fetch('../extension.json')
.then(response => {
if (!response.ok) {
throw new Error('Not ok');
}
return response.json();
})
.then(data => {
const element = document.querySelector('.extName');
if (element) {
element.textContent = data.name;
}
})
.catch(error => console.error('Error fetching JSON:', error));
});
</script>
</body>
</html>
And the content of my JSON file (extension.json) is:
{
"name": "If you read this, it's working"
}
It seems that only SketchUp 2024 can successfully fetch and display the JSON data. Could there be compatibility issues with older versions of SketchUp regarding HTML and JSON interaction, or am I missing something in my code that is essential for earlier versions? Any guidance or suggestions would be greatly appreciated.


