Hopefully this is a straightforward question, but I want to read a text file that is in the same location as my .js file using JavaScript. I've read about the FileReader and sort of understand the API there, but all of the examples I've seen use <input type="file" /> as a way of capturing the File object necessary to be read by the FileReader.
In addition, how difficult would it be to read a text file that contains JSON data? Ideally I just want to store some data as JSON and read it in using JavaScript. Any help would be greatly appreciated. Thanks!
So I've gotten some good responses, but I'm going to expand my question a little. Thank you so far for what you've provided!
I'm using TypeScript, so jQuery is a little tricky (using the projection). But I found out about XMLHTTPRequest. Is this also a good solution to this problem? Thanks!