场景: 当页面文件.html作为本地文件打开(即IE路径为file:///开头的)的时候,需要访问本地文本文件的内容时。
本地文件目录在页面文件的子文件夹。
目录结构
|
|-test.html
|-Scripts
    |-data.txt
 
需要访问data.txt的内容。
代码:
$.get('Scripts/data.txt').success(function(content){
    // content就为文件data.txt的文本内容了,注意txt文件的编码需要与html文件的编码一致,最好保存成utf-8
});

 

 

 

相关文章:

  • 2021-07-05
  • 2021-12-12
  • 2021-11-12
  • 2021-08-08
  • 2022-12-23
  • 2021-09-06
  • 2021-11-19
  • 2021-06-04
猜你喜欢
  • 2022-12-23
  • 2021-05-05
  • 2022-12-23
  • 2021-08-20
  • 2022-02-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案