Javascript, how to read local file?

前端 未结 5 973
长情又很酷
长情又很酷 2020-11-30 14:28

I try to read a local file from server. I have been \"googling\" this topic for a while now, and some say it\'s impossible, others that it can be done. During this search I\

5条回答
  •  攒了一身酷
    2020-11-30 14:43

    The function you pass in as a callback should comprise the code which actually processes the results of your initial ajax call. For example, at its simplest:

    alert("RESPONSE: " + xmlhttp.responseText;
    

    However, we need to clarify what you're trying to do: read a file that's stored on the server? If so, that target file has to be accessible from the web (so that you can pass over its URL to your ajax call), else your code simply won't work.

提交回复
热议问题