weixin_33691700 2015-12-14 11:17 采纳率: 0%
浏览 47

文件协议Ajax请求

I have made a project whose structure is like this

My project structure

When I run my index.html from firefox, it is working fine.

But I open it with my chrome it is giving CORS error. Chrome url

Chrome Error

Now my problem is that chrome doesnot support file:// protocol ajax request & as I have distribute to my project to others I don't want other to run on firefox only.

Internally I am using ajax call in project, to load the resources. Can Somebody suggest how to bypass that ajax call to load resources?? Is there some solution or any third party js which can help me.

Note: Please don't suggest to use XAMPP, apache etc where I can put my project and run as localhost for chrome as I don't want user to force to download these to run my project. Please give other useful solution where I can do some change in code & it works for everyone.

Here are the links from which you could understand my problem better.

Ajax in Jquery does not work from local file

AJAX code do not run locally

AJAX request using jQuery does not work

  • 写回答

1条回答 默认 最新

  • 叼花硬汉 2015-12-14 11:24
    关注

    Embed the data directly into the JavaScript or HTML and read it from there.

    The data isn't going to be changing based on user input or the contents of a database, so having it in a separate "http" resource doesn't bring huge benefits.

    If you want to store the data in XML to make it easier to edit in your development environment, then write a build tool to bundle it up into an embedded format before distributing.

    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵