Extjs Sencha touch 2:获取XMLHttpRequest无法加载文件:data.json.Origin null不被访问控制Allow Origin允许

Extjs Sencha touch 2:获取XMLHttpRequest无法加载文件:data.json.Origin null不被访问控制Allow Origin允许,extjs,sencha-touch,sencha-touch-2,Extjs,Sencha Touch,Sencha Touch 2,我正试图从本地服务器上托管的json文件加载一些数据,但出现错误“XMLHttpRequest无法加载”http://localhost:8080/data.json?_dc=1355779280677&page=1&start=0&limit=25. Access Control Allow Origin不允许原点为null。“应用程序加载后立即执行。我的列表中没有记录 我的代码如下 Ext.define('POC.view.HomePage', { extend: 'Ext.TabP

我正试图从本地服务器上托管的json文件加载一些数据,但出现错误“
XMLHttpRequest无法加载”http://localhost:8080/data.json?_dc=1355779280677&page=1&start=0&limit=25. Access Control Allow Origin不允许原点为null。“
应用程序加载后立即执行。我的列表中没有记录

我的代码如下

Ext.define('POC.view.HomePage', {
    extend: 'Ext.TabPanel',
    requires:['Ext.TitleBar','Ext.dataview.List',
    'Ext.Ajax','Ext.data.proxy.Ajax'],
    xtype:'homePage', 
    alias: 'widget.wuHomePageView',

     config: {
     fullscreen: true,
        items: [
        {
          title: 'Home',
          iconCls: 'home',

          items: [

       {
    xtype: 'list',
        title: 'Sample',
        height: '100%',
        onItemDisclosure: true,

        store: {
        autoLoad: true,
        fields: ['name'],
            proxy: {
           type: 'json',
           url: 'http://localhost:8080/data.json',
            reader: {
               type: 'ajax',
               rootProperty: 'stores'
                }
                }
                },
             itemTpl: '{name}',

                }],

                },
            {
            title: 'Contact',
            iconCls: 'user',
            html: 'Contact Screen'
                }
            ]
            },

});
{
    "stores": [
        {
            "name": "Science Gallery",
            "logo": "sciencegallery.jpg",
            "desc": "Get some food",
            "telephone": "016261234",
            "city": "Dublin",
            "add1": "Pearse Street",
            "post": "2",
            "country": "Ireland",
            "latitude": "53.34422",
            "longitude": "-6.25006",
            "menu": [
                {
                    "item": "SC Sandwich"
                },
                {
                    "item": "SC Toasted Sandwich"
                },
                {
                    "item": "SC Panini"
                },
                {
                    "item": "SC Ciabatta"
                },
                {
                    "item": "SC Burrito"
                }
            ]
        },
        {
            "name": "Spar",
            "logo": "spar.jpg",
            "desc": "Get some food",
            "telephone": "016261234",
            "city": "Dublin",
            "add1": "Mayor Street",
            "post": "2",
            "country": "Ireland",
            "latitude": "53.34422",
            "longitude": "-6.25006",
            "menu": [
                {
                    "item": "Spar Sandwich"
                },
                {
                    "item": "Spar Toasted Sandwich"
                },
                {
                    "item": "Spar Panini"
                },
                {
                    "item": "Spar Ciabatta"
                },
                {
                    "item": "Spar Burrito"
                }
            ]
        }
    ]
}
我的Json文件如下所示

Ext.define('POC.view.HomePage', {
    extend: 'Ext.TabPanel',
    requires:['Ext.TitleBar','Ext.dataview.List',
    'Ext.Ajax','Ext.data.proxy.Ajax'],
    xtype:'homePage', 
    alias: 'widget.wuHomePageView',

     config: {
     fullscreen: true,
        items: [
        {
          title: 'Home',
          iconCls: 'home',

          items: [

       {
    xtype: 'list',
        title: 'Sample',
        height: '100%',
        onItemDisclosure: true,

        store: {
        autoLoad: true,
        fields: ['name'],
            proxy: {
           type: 'json',
           url: 'http://localhost:8080/data.json',
            reader: {
               type: 'ajax',
               rootProperty: 'stores'
                }
                }
                },
             itemTpl: '{name}',

                }],

                },
            {
            title: 'Contact',
            iconCls: 'user',
            html: 'Contact Screen'
                }
            ]
            },

});
{
    "stores": [
        {
            "name": "Science Gallery",
            "logo": "sciencegallery.jpg",
            "desc": "Get some food",
            "telephone": "016261234",
            "city": "Dublin",
            "add1": "Pearse Street",
            "post": "2",
            "country": "Ireland",
            "latitude": "53.34422",
            "longitude": "-6.25006",
            "menu": [
                {
                    "item": "SC Sandwich"
                },
                {
                    "item": "SC Toasted Sandwich"
                },
                {
                    "item": "SC Panini"
                },
                {
                    "item": "SC Ciabatta"
                },
                {
                    "item": "SC Burrito"
                }
            ]
        },
        {
            "name": "Spar",
            "logo": "spar.jpg",
            "desc": "Get some food",
            "telephone": "016261234",
            "city": "Dublin",
            "add1": "Mayor Street",
            "post": "2",
            "country": "Ireland",
            "latitude": "53.34422",
            "longitude": "-6.25006",
            "menu": [
                {
                    "item": "Spar Sandwich"
                },
                {
                    "item": "Spar Toasted Sandwich"
                },
                {
                    "item": "Spar Panini"
                },
                {
                    "item": "Spar Ciabatta"
                },
                {
                    "item": "Spar Burrito"
                }
            ]
        }
    ]
}
请帮忙


谢谢

没有像json代理这样的东西!您必须使用ajax代理:

proxy: {
   type: 'ajax',
   .....
}

没有像json代理这样的东西!您必须使用ajax代理:

proxy: {
   type: 'ajax',
   .....
}

谢谢我将代理更改为ajax。我收到“XMLHttpRequest无法加载。访问控制不允许原点为null。允许原点。”错误。有什么输入吗?那是因为您正在进行跨站点ajax调用。但这是另一个问题。您必须配置服务器以接受来自您站点的调用。您也可以使用jsonp代理,但是如果这两个站点都是您的,我不会使用它。使用jsonp作为最新的资源。谢谢。这个问题是由于chrome强加的一些安全约束造成的,ajax请求失败了,因此我不得不禁用google chrome安全性。下面的博客对如何禁用google chrome的安全性以允许跨浏览器调用hanks很有帮助。我将代理更改为ajax。我收到“XMLHttpRequest无法加载。访问控制不允许原点为null。允许原点。”错误。有什么输入吗?那是因为您正在进行跨站点ajax调用。但这是另一个问题。您必须配置服务器以接受来自您站点的调用。您也可以使用jsonp代理,但是如果这两个站点都是您的,我不会使用它。使用jsonp作为最新的资源。谢谢。这个问题是由于chrome强加的一些安全约束造成的,ajax请求失败了,因此我不得不禁用google chrome安全性。下面的博客对如何禁用google chrome的安全性以允许跨浏览器调用很有帮助