0

I want to have a Navigation view. I am trying to populate the list in Sencha Touch using a JsonP proxy.

Here's the sample code snippet of what I have tried till now :

var view = Ext.define('MyApp.view.NavigateView', {
    extend: 'Ext.navigation.View',
    xtype:'navigateview',

    config : {
        fullscreen:true,
        styleHtmlContent:true,
        scrollable:true,

        items : [
            {
                title:'Navigation',
                items : [
                    {
                        xtype:'list',
                        store: {
                            fields : ['title','author'],
                            proxy : {
                                type:'jsonp',
                                url:'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://feeds.feedburner.com/SenchaBlog',
                                    reader: {
                                         type: 'json',
                                         rootProperty: 'responseData.feed.entries'
                                    }
                            },
                            autoLoad:true,
                        },
                        itemTpl:'<div class="contact">{title} <strong>{author}</strong></div>',
                        listeners : {
                            itemtap : function(){
                                Ext.Msg.alert('Called');
                                }
                            }
                        }
                ],

            }
        ]   
   }
});

But the problem is, my list is not getting populated. No items are being shown up in the list.

Also, I am constantly getting this error on console.

XMLHttpRequest cannot load http://api.tinyhippos.com/xhr_proxy?tinyhippos_apikey=ABC&tinyhippos_rurl=list.php%3F_dc%3D1334462633038%26page%3D1%26start%3D0%26limit%3D25. Origin http://localhost is not allowed by Access-Control-Allow-Origin.

Anyone please guide ? Anything that I am missing here ?

4

2 回答 2

2

在跨域中使用 AJAX 请求时,我遇到了同样的错误。看看这里

您必须确保使用 jsonp 正确配置服务器部分

作为第一步,确定当您在浏览器中禁用网络安全时您的应用程序是否能正常运行

找到您的 chrome 安装目录,然后输入您的 cmd: chrome --disable-web-security

于 2012-04-15T12:50:52.947 回答
0

您的Ext.navigation.View对象包含一个包含您的列表的Ext.Component对象(xtype 未定义,因此默认为“组件”)。如果您将列表直接作为视图的一个项目,它将被渲染:

var view = Ext.define('MyApp.view.NavigateView', {
  extend: 'Ext.navigation.View',
  xtype: 'navigateview',

  config : {
    fullscreen: true,
    styleHtmlContent: true,
    scrollable: true,

    items : [{
      title: 'Navigation',
      xtype: 'list',
      store: {
        fields: ['title','author'],
        proxy: {
          type: 'jsonp',
          url: 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://feeds.feedburner.com/SenchaBlog',
          reader: {
            type: 'json',
            rootProperty: 'responseData.feed.entries'
          }
        },
        autoLoad:true
      },
      itemTpl: '<div class="contact">{title} <strong>{author}</strong></div>'
    }]
  }
});

注意1:不确定为什么您的代码不起作用。

注意2:您提到的错误与您的代码段无关

于 2012-04-15T11:11:07.347 回答