In my project using Python 3.6.4 and Django 2.0, I am facing an issue with loading a JavaScript file script.js in an index.html. The problem lies in correctly specifying the path to a JSON file data.json.
Despite utilizing a XmlHttpRequest object, the index.html is not displaying the information from data.json as intended.
function makeRequest(url){
...
http_request = new XMLHttpRequest();
http_request.open('GET', url, true);
}
...
window.onload = function(){
makeRequest("here/have/problems");
}
Tree of my files
https://i.sstatic.net/0tFcu.png
Within index.html, I am using:
{% load static %}
...
<script src="{% static 'bar/scripts/script.js' %}"></script>
This part works well. However, when trying to specify "bar/data/data.json" inside script.js, it doesn't work as expected. Please guide me on resolving this issue.