fyiesk 2016-11-02 09:39 采纳率: 0%
浏览 987

dojo gridx模块在谷歌浏览器和火狐浏览器中出现XMLhttprequest跨域问题

我的项目在d盘,然后用的arcgis api for JavaScript,又下载了个gridx模块,都放在了IIS对应的位置,位置都对,调试的时候因为webstorm会自己生成一个域,就导致和IIS下的不是同源了,网上说的在谷歌浏览器快捷方式里加--allow-file-access-from-files,试过了,不管用。用IE8调试没问题,IE8好像允许跨域,求解决方法,错误和源码如下,错误是分别在谷歌和火狐中的。没有钱,所以没办法悬赏,只求大牛帮忙

 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>gridx test</title>
<link rel="stylesheet" href="http://localhost/arcgis_js_api/library/3.18/3.18/gridx/resources/claro/Gridx.css">

<script src="http://localhost/arcgis_js_api/library/3.18/3.18/dojo/dojo.js"></script>
</head>
<body>
<div id="gridContainer"></div>
<script type="text/javascript">
require(["dojo/parser", "dojo/store/Memory", "gridx/Grid", "gridx/core/model/cache/Sync", "dojo/domReady!"],
function (parser, Memory, Grid, Cache){
parser.parse();

var store = new Memory({
data: [
{ id: 1, name: 'John', score: 130, city: 'New York', birthday: '1980/2/5'},
{ id: 2, name: 'Alice', score: 123, city: 'Washington', birthday: '1984/3/7'},
{ id: 3, name: 'Lee', score: 149, city: 'Shanghai', birthday: '1986/10/8'},
{ id: 4, name: 'Mike', score: 100, city: 'London', birthday: '1988/8/12'},
{ id: 5, name: 'Tom', score: 89, city: 'San Francisco', birthday: '1990/1/21'}
]
});

var structure = [
{ id: 'name', field: 'name', name: 'Name', width: '50px'},
{ id: 'city', field: 'city', name: 'City'},
{ id: 'score', field: 'score', name: 'Score', width: '80px'}
];

//Create grid widget.
var grid = Grid({
id: 'grid',
cacheClass: Cache,
store: store,
structure: structure
});

//Put it into the DOM tree. Let's assume there's a node with id "gridContainer".
grid.placeAt('gridContainer');

//Start it up.
grid.startup();
});
</script>
</body>
</html>

图片说明

图片说明

  • 写回答

1条回答 默认 最新

  • Go 旅城通票 2016-11-02 09:55
    关注

    跨域了,要在发起ajax请求的域名做个代理页面负责请求远程数据,ajax请求此页面而不是直接请求跨域页面

    ie默认也不允许跨域的,除非你配置过ie浏览器安全。

    或者将跨域页面数据改为jsonp的,而不是单单数据,jsonp是什么自己搜索下,简单来说就是一段可以执行的js代码,格式如 回调函数(数据)

    评论

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码