我正在使用extjs进行应用程序,但是当我验证了一些像xml grid这样的例子时,我发现它不能用于chrome和上面提到的其他一些浏览器,但是它可以正常运行...
你可以帮我解决这个问题....这里是代码..以防万一......Ext.onReady(function(){
var store = new Ext.data.Store({
url: 'http://dev.sencha.com/deploy/dev/examples/grid/sheldon.xml',
reader: new Ext.data.XmlReader({
record: 'Item',
id: 'ASIN',
totalRecords: '@total'
}, [
{name: 'Author', mapping: 'ItemAttributes > Author'},
'Title', 'Manufacturer', 'ProductGroup'
])
});
// create the grid
var grid = new Ext.grid.GridPanel({
store: store,
columns: [
{header: "Author", width: 120, dataIndex: 'Author', sortable: true},
{header: "Title", width: 180, dataIndex: 'Title', sortable: true},
{header: "Manufacturer", width: 115, dataIndex: 'Manufacturer', sortable: true},
{header: "Product Group", width: 100, dataIndex: 'ProductGroup', sortable: true}
],
renderTo:'example-grid',
width:540,
height:200
});
store.load();
});
它的html文件是:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>XML Grid Example</title>
<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../../ext-all-debug.js"></script>
<script type="text/javascript" src="xml-grid.js"></script>
<link rel="stylesheet" type="text/css" href="grid-examples.css" />
<link rel="stylesheet" type="text/css" href="../shared/examples.css" />
</head>
<body>
<script type="text/javascript" src="../shared/examples.js"></script>
<h1>XML Grid Example</h1>
<div id="example-grid"></div>
</body>
</html>
答案 0 :(得分:1)
Firefox,Chrome和Safari可能会阻止您的JavaScript调用“http://dev.sencha.com/deploy/dev/examples/grid/sheldon.xml”。
将XML下载到您的计算机并调整商店声明中的URL。
答案 1 :(得分:0)
这是因为"Same origin policy"。请阅读它以获得更好的解释。