天天看點

關于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