How to access my local JSON file in my JS script?

Firstly, is your "lecturer" an ex-mechanic, cause those prices are from the 90s.

Secondly. How on this green earth are you suppose to serve content without a server.

Either you are ill informed or your "lecturer" is. This is a web site, not a text file.

Have you considered a low tech solution, and just parsing the text using json, on change / input

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea

And finally, you need to parse strings out of session storage, you are dealing with a string, not an object, and use a try catch please.
 
Firstly, is your "lecturer" an ex-mechanic, cause those prices are from the 90s.
No no, lol. I got the prices from the business itself, not my lecturer lol.
Secondly. How on this green earth are you suppose to serve content without a server.

Either you are ill informed or your "lecturer" is. This is a web site, not a text file.
I know about the server thing, that's why I'm frustrated. Since I know using a server, I could've used AJAX a long time ago to get the damned file, and I would've been done with my assignment by now...

And what's with "lecturer" in quotations?
And finally, you need to parse strings out of session storage, you are dealing with a string, not an object, and use a try catch please.
I got it. Did this:
JavaScript:
let tableDiv = document.createElement("table");
    console.log(getFromSessionStorage(keys[9]));
    servicesDiv.appendChild(tableDiv);
    tableDiv.innerHTML = getFromSessionStorage(keys[9]);
 
So I just emailed my lecturer. She says that we can use a server...

So I wasted three days to try and find an alternative solution to a server, instead of just using a damn server.

Thanks to everyone who participated and helped in this thread.

I'm gonna go bash my head in now...
 
No no, lol. I got the prices from the business itself, not my lecturer lol.

I know about the server thing, that's why I'm frustrated. Since I know using a server, I could've used AJAX a long time ago to get the damned file, and I would've been done with my assignment by now...

And what's with "lecturer" in quotations?
Lecturer in quotations, cause the person in charge of teaching you is doing a so so job at best, by the looks of things.
 
Top
Sign up to the MyBroadband newsletter
X