weixin_33675507 2014-12-09 14:57 采纳率: 0%
浏览 253

Ajax调用本地csv文件

The folder structure is: HOME\htmlhelp\wwhelp\wwhimpl\js\scripts HOME\auxi\

I can read a csv file (located in the HOME\htmlhelp dir) from a js file located in the HOME\htmlhelp\wwhelp\wwhimpl\js\scripts dir using the following: var file_path="../../../../../htmlhelp/rule_mapping.csv";

However, the same js file (from the same location) cannot read the same csv file in the HOME\auxi\ directory! Am using the path as var file_path="../../../../../auxi/rule_mapping.csv";

It throws an "NS_ERROR_DOM_BAD_URI: Access to restricted URI denied" error. I have checked the file permissions and stuff but no luck. Any help would be appreciated.

  • 写回答

1条回答 默认 最新

  • weixin_33739541 2014-12-09 15:08
    关注

    The problem lies within:

    var file_path="../../../../../htmlhelp/rule_mapping.csv";
    

    It's not possible to traverse up to paths out of the root directory where the document is located.

    Assuming you work under UNIX (Linux/Mac), one solution would be to create a symbolic link on the root directory of the document, such as (executing from the scripts directory):

    ln -s ../../../../../htmlhelp/rule_mapping.csv rule_mapping.csv
    

    And changing the file_path to:

    var file_path="./rule_mapping.csv";
    

    I hope this helps!

    评论

报告相同问题?

悬赏问题

  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥85 maple软件,solve求反函数,出现rootof怎么办?
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题