我正在尝试运行一个在web2py服务器和基于web2py的客户端显示可视化数据的项目。当同时运行服务器和客户端时,客户端的chrome控制台显示:
XMLHttpRequest cannot load http://127.0.0.1:8075/?format=json.
No 'Access-Control- Allow-Origin' header is present on the requested resource.
Origin 'http://127.0.0.1:8080' is therefore not allowed access. (index):1
[ERROR] Cannot connect to data server: http://127.0.0.1:8075?format=json 我在linux上用web2py2.9.5运行上面的代码。
发布于 2014-04-29 22:16:47
看起来您的web2py客户端页面在端口8080上提供服务,但随后向端口8075发出Ajax请求,这违反了web浏览器强制执行的same origin policy。
如果您不能从同一来源提供这两种服务,您可以通过使用JSONP或设置CORS来解决此问题。
https://stackoverflow.com/questions/23359947
复制相似问题