weixin_33734785 2015-10-21 11:34 采纳率: 0%
浏览 57

JSON at file://协议

So, I have to open my web app, like file. So the browser opens .html file and at the adres bar protocol used is file://. But at the script I have to open .json file and load it to variable.

I have tried $.ajax request with data type jsonp, I have tried requirejs who kind a load file but gets syntax error from json file so it doesnt load into variable. Same happens if I just do this

<script type="text/javascript" src="path/to/.json"></script>

Is there another way? App doesn't use PHP it needs to run from file:// protocol with not changing browser settings.

Thanks

  • 写回答

2条回答 默认 最新

  • weixin_33709219 2015-10-21 11:36
    关注

    Embed the data directly into the page.

    There's no network, so it won't cause a performance penalty. It's static, so you don't lose the ability to generate it dynamically.

    评论

报告相同问题?