I’m trying to follow
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
To display the results from a JSON file, so first things first and am trying to load the object into a variable
var content = file_get_contents("../data/cooling-areas.json");
but
but If I check if the URL exists
from
I see
So if the file exists, why would the variable be undefined?
igor_g
September 17, 2020, 5:12pm
2
You try to use PHP function in JS?
1 Like
The error is not referring to the file, but the function. Are you sure all your dependencies are loading, otherwise you need to write the import function in your cooling_areas.js file.
something similar to:
function file_get_contents(filename) {
fetch(filename).then((resp) => resp.text()).then(function(data) {
return data;
});
}
system
Closed
December 18, 2020, 12:59am
4
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.