arcgis api for JavaScript _跨域请求
分享
arcgis api for JavaScript 中出现跨域请求是常见问题,
通常出现类似如下错误消息类似:
XMLHttpRequest cannot load http://10.32.2.70:8399/ArcGIS/rest/info?f=json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:58374' is therefore not allowed access.
什么是跨域:http://blog.csdn.net/lambert31 ... 83775
怎样解决:
参考 https://developers.arcgis.com/ ... .html
esriConfig.defaults.io.corsEnabledServers 这一段,把要访问的服务对应的server地址添加进去:
require(["esri/config"], function(esriConfig) {
esriConfig.defaults.io.corsEnabledServers.push("localhost:6080");
});
如上代码所示,localhost:6080 即 server 服务所在arcgis server 地址。
以上为 arcgis api for JavaScript 3.x 所使用的方法,arcgis api for JavaScript 4.x 修改为: 参考:https://developers.arcgis.com/ ... .html 其中的 corsEnabledServers 这一段
Example: // Add a known server to the list. require(["esri/config"], function(esriConfig) { esriConfig.request.corsEnabledServers.push("localhost:6080"); }); 实际代码如下图所示(以 4.x 版本为例):
如果还不行就需要配置代理,参考文档https://developers.arcgis.com/ ... .html
文章来源:http://www.cnblogs.com/mumu122GIS/p/8482445.html
通常出现类似如下错误消息类似:
XMLHttpRequest cannot load http://10.32.2.70:8399/ArcGIS/rest/info?f=json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:58374' is therefore not allowed access.
什么是跨域:http://blog.csdn.net/lambert31 ... 83775
怎样解决:
参考 https://developers.arcgis.com/ ... .html
esriConfig.defaults.io.corsEnabledServers 这一段,把要访问的服务对应的server地址添加进去:
require(["esri/config"], function(esriConfig) {
esriConfig.defaults.io.corsEnabledServers.push("localhost:6080");
});
如上代码所示,localhost:6080 即 server 服务所在arcgis server 地址。
以上为 arcgis api for JavaScript 3.x 所使用的方法,arcgis api for JavaScript 4.x 修改为: 参考:https://developers.arcgis.com/ ... .html 其中的 corsEnabledServers 这一段
Example: // Add a known server to the list. require(["esri/config"], function(esriConfig) { esriConfig.request.corsEnabledServers.push("localhost:6080"); }); 实际代码如下图所示(以 4.x 版本为例):
如果还不行就需要配置代理,参考文档https://developers.arcgis.com/ ... .html
文章来源:http://www.cnblogs.com/mumu122GIS/p/8482445.html
0 个评论
相关问题
- 如何优雅的使用ArcGIS知乎?
- 建设ArcGIS知乎平台的目和意义?
- ArcGIS知乎社区改进意见征集
- 【抽奖结果已出】ArcGIS知乎社区活动 之 你不知道的地理空间革命【转发分享有奖】【附奖品寄送照片】
- 苹果系统下可以使用arcgis 吗?
- arcgis版本兼容性
- 请问ArcGIS适合在局域网内用javaweb做二次开发吗?
- ArcGIS 知乎社区活动 之 2018拒绝boring,来,在线答题赢kindle【结果已出,速来领奖】
- ArcGIS 知乎社区活动 之 字幕组加鸡腿暨KBP字幕组招新【获奖名单公布与优秀作品展示】
- 请问大神们,怎么用ArcGIS做城镇间经济联系强度的图?
- 在Visual studio 2015 中使用 Arcgis API for JavaScript v3.16 如何实现代码智能提示?