关于Chrome浏览器使用ajax访问本地文件报 Cross origin requests are only supported for HTTP

先浏览了http://blog.csdn.net/rywaqpf/article/details/44836965,然后又奔到了https://stackoverflow.com/questions/10752055/cross-origin-requests-are-only-supported-for-http-error-when-loading-a-local/23758738#23758738,受其中的高票答案启发:

解决这个问题的方式有好几种。除了CMD的allow-file-access-from-files(自己还未试过),还可以在自己的PC上装一个服务器(刚好,前期装了LAMP),然后把文件(相关的html、js、css等等)拷贝过去,然后以类似http://localhost/XXX.html的形式访问,就可以了。


https://stackoverflow.com/questions/10752055/cross-origin-requests-are-only-supported-for-http-error-when-loading-a-local/23758738#23758738    中的高票答案(建议直接点看链接):

My crystal ball says that you are loading the model using either file:// or C:/, which stays true to the error message as they are not  http://

So you can either install a webserver in your local PC or upload the model somewhere else and use jsonp and change the url to http://example.com/path/to/model

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章