1

I have an json file in my desktop folder and i try to access in my html file but i get following error.

XMLHttpRequest cannot load file://localhost/Users/p41technologies/Desktop/Json%20in%20Html/json-data.json. Origin null is not allowed by Access-Control-Allow-Origin.

I even tryied to,

open -a "Google Chrome" --args --allow-files-access-from-files

and

open -a "Google Chrome" --disable-web-security

but it didn't work. I still get the same error. Why does it happen and how to solve it.

4

1 回答 1

0

您遇到的安全功能应该可以防止恶意脚本从本地文件系统中读取。

你看过html5 文件/文件阅读器 api吗?有一个带有工作演示的教程。你也可以看看这里

于 2013-07-15T07:28:29.957 回答