是否可以对本地文件使用 xhr?

Is it possible to use xhr for local files?

我找不到任何最近的答案,是否可以使用 AJAX 请求加载本地文件。因此,在我的站点中,我的 Web 服务器上有一个名为 data.json 的文件,是否可以使用相对路径而不是使用其 Web 可访问性 url 从我的 Js 文件请求日期,因此会产生速度成本.

来源为 http://…https://… 的网站无法通过 file:///…. Otherwise nothing could stop any arbitrary website from stealing your local data. Probably the buzzword you are looking for is localStorage.

访问内容

另请参阅:noscript's ABE,一个流行的插件,它使本地和远程内容之间的分离更加严格。

另请参阅:“Firefox exploit found in the wild”,当分离失败时。