标签:
使用Store ajax的方式来获取数据
Ext.onReady(function() { var store = new Ext.data.JsonStore({ // store configs storeId: ‘myStore‘, autoLoad: true, proxy: { type: ‘ajax‘, url: ‘getImage.php‘, reader: { type: ‘json‘, root: ‘images‘, idProperty: ‘name‘, //getData的函数最先触发 //这里配置过getData就相当于把数据取走了 //后面on事件 函数就不能通过records取到数据了 还是可以通过store.getProxy().getReader().rawData去到数据 // afterRequest 则根本取不到数据 // getData: function(data){ // console.log(‘getData in reader‘); // console.log(data); // } }, afterRequest: function(req, res) { console.log("After Request!", req.operation.response); } }, //alternatively, a Ext.data.Model name can be given (see Ext.data.Store for an example) fields: [‘name‘, ‘url‘, { name: ‘size‘, type: ‘float‘ }, { name: ‘lastmod‘, type: ‘date‘ }] }); store.load(); //会调用多次.. store.on({ ‘load‘: function(store, records, success, opts) { console.log(‘on1‘); console.log(success); //records 是 [] console.log(records); //PS rawData是一个{} console.log(store.getProxy().getReader().rawData); } }, this, {single:true}); store.on(‘load‘, function(store, records, success, eOpts ){ console.log(‘on2‘); console.log(success); console.log(records); console.log(store.getProxy().getReader().rawData); }); store.load({ callback: function(records, opts, success) { console.log(‘load‘); console.log(success); console.log(records); } }); // console.log(store); });
标签:
原文地址:http://www.cnblogs.com/cart55free99/p/4530275.html