首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Ajax >

extjs ajax 的同步有关问题

2013-01-28 
extjs ajax 的同步问题我用的是Extjs2.0.2,我写好了一个从后台服务器获取数据的方法,只有当这个方法执行完

extjs ajax 的同步问题
我用的是Extjs2.0.2,我写好了一个从后台服务器获取数据的方法,只有当这个方法执行完之后下面的程序才能正确运行,但是我发现这个Ext.Ajax.request();方法是异步的啊,还没等一些值赋完,就往下走了,举个简单的例子


[解决办法]
var store = new Ext.data.Store({
                        pageSize: limit,
                        //autoLoad: true,
                        proxy: {
                            type: 'ajax',
                            url: 'queryAction!getData?startDate=' + startDate + '&endDate=' + endDate + '&dic_id=' + dic_id + '&drillDown=true',


                            method: 'POST',
                            reader: {
                                type: 'json',
                                root: 'gridData',
                                totalProperty: 'totalCount',
                                //数据的总记录条数   
                            }
                        },
                        fields: [{
                            name: 'dic_id'
                        },
                        {
                            name: 'type_name'
                        },
                        {
                            name: 'name'
                        },
                        {
                            name: 'TV',
                            type: 'date',
                            dateFormat: 'Y-m-d h:i:s'
                        },
                        {


                            name: 'VAL_PP',
                            type: 'float'
                        },
                        {
                            name: 'VAL_NP',
                            type: 'float'
                        },
                        {
                            name: 'VAL_TD',
                            type: 'float'
                        },
                        {
                            name: 'VAL_FLOW',
                            type: 'float'
                        },
                        {
                            name: 'VAL_TD_P',
                            type: 'float'
                        },
                        {
                            name: 'VAL_FLOW_P',
                            type: 'float'
                        }]
                    });


                    store.load({
                        scope: this,
                        callback: function(records, operation, success) {
                            if (records.length <= 0) {
                                Ext.Msg.alert("提示", "下钻已到底层!");
                                drilldownwindow.close();
                                return;
                            }
                        }
                    });


LZ看看能看明白么
[解决办法]
引用:
JavaScript code?123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263var store = new Ext.data.Store({                      ……
对头,放在回调函数中,可以避免那样的问题

热点排行