I have on my web server a JS script that I want to be able to read files. My filesystem is like this:
> Root
index.html
read.js
> files
file.txt
You want to be using XMLHttpRequest
, like Gabriel has suggested.
You seriously need to read up on it, since it is very configurable and you need to understand the workflow in order to implement it. You will run into problems initially, if you are cross origin scripting.
Here is an example I mocked up for you: