Read A Server Side File Using JavaScript

后端 未结 5 1188
情书的邮戳
情书的邮戳 2021-02-04 03:11

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
         


        
5条回答
  •  庸人自扰
    2021-02-04 03:43

    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:

    
    

提交回复
热议问题