0

我的代码没有显示任何错误,我的 php 文件也在响应(萤火虫报告)。但是网格没有显示任何数据。我试图从http://dev.sencha.com/deploy/ext-3.4.0/examples/feed-viewer/view.html获得帮助,但无法理解!这个想法是为程序提供一个 rss 提要 url,它应该从该 url 获取数据,然后 php 文件以适当的 xml 格式排列它,就像 ExtJS 示例(来自上面的链接)一样,到目前为止,程序运行良好,萤火虫说响应是一个xml,但现在,它没有加载。代码:

var remoteProxy = new Ext.data.HttpProxy({
        url : 'feed-proxy.php'
    });
var store = new Ext.data.Store({
        proxy : remoteProxy,
        id : 'ourRemoteStore',
        reader : new Ext.data.XmlReader({
                    record : 'item'
                }, [{
                            name : 'title',
                            mapping : 'title'
                        }])
    });
loadFeed = function(url) {
store.baseParams = {
    feed : url
};
store.load();
console.log(store.getCount());
}
loadFeed('http://sports.yahoo.com/nba/rss.xml');

var mWIn = new Ext.Window({
        title : 'My Window',
        width : 500,
        height : 400,
        layout : 'fit',
        items : [{
                    xtype : 'grid',
                    store : store,
                    id : 'myGrid',
                    loadMask : true,
                    columns : [{
                                id : 'title',
                                header : "Title",
                                dataIndex :'title',
                                sortable : true,
                                width : 420
                            }]

                }]
    }).show();
    Ext.getCmp('myGrid').ownerCt.doLayout();

和 php 文件代码是:

 <?php
 // this is an example server-side proxy to load feeds
 if(isset($_REQUEST['feed'])){
 $feed = $_REQUEST['feed'];
 if($feed != '' && strpos($feed, 'http') === 0){
header('Content-Type: text/xml');
$xml = file_get_contents($feed);
$xml = str_replace('<content:encoded>', '<content>', $xml);
$xml = str_replace('</content:encoded>', '</content>', $xml);
$xml = str_replace('</dc:creator>', '</author>', $xml);
echo str_replace('<dc:creator', '<author', $xml);
return;
 }
 }
 ?>
4

0 回答 0