每60秒刷新JSON存储 - EXT JS 4

3
    var MarkerStore = Ext.create('Ext.data.JsonStore', {
            model: 'GoogleMarkerModel',
            autoLoad: true,
            proxy: {
                type: 'ajax',
                url: 'get-googlemarker.php',
                baseParams: {  //here you can define params you want to be sent on each request from this store
                            mainid: 'value1'
                            },
                reader: {
                    type: 'json',
                    idProperty:'MainID',
                }

            }
        });

setTimeout(MarkerStore, 60000);

这个正确吗?因为我每60秒仍然无法获取任何新数据。

1个回答

3

我只是使用了JavaScript中的setInterval函数。Sencha在他们的livegrid示例中也使用了这个函数。

例如:

// reload the stores once and then repeatedly every 60 seconds
MarkerStore.load();
setInterval(function() {
    MarkerStore.load();
}, 60000);

为了给你一个更完整的答案,你使用的setTimeout javascript函数只会在指定的毫秒数后执行一次代码。而setInterval则是用来重复执行一个函数的。
另外请注意,setIntervalsetTimeout的第一个参数都是一个javascript函数。在你上面的代码片段中,你将store对象本身作为第一个参数传递,这样做根本不会导致它被调用。这个页面有更多的数据。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接