سؤال

i was using extjs for an application but when i verified some of the examples like xml grid, i found that it's not working in chrome and some other browsers as mentioned above but it works fine in ie...

can you please help me solve this issue....here is the code..just in case......

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();
});

the html file for it is:

<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>
هل كانت مفيدة؟

المحلول 2

it is because of the "Same origin policy". Please read it for better explanation.

نصائح أخرى

Firefox, Chrome and Safari probably prevent your JavaScript from calling 'http://dev.sencha.com/deploy/dev/examples/grid/sheldon.xml'.

Download the XML to your machine and adjust the URL in your store declaration.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top