PDA

View Full Version : combobox remote load problem with GET method



silvyivy
7 May 2009, 11:02 AM
Hi, I have to load some record from a server into a combobox, the code I use is:

var storeRes = new Ext.data.Store({
url : Data.ServerName+'/resource.xml',
method : 'GET',
id : 'res',
reader : new Ext.data.XmlReader(
{ record : 'resource', id: 'id'},
[{ name : 'name', type: 'string' } ]
),
listeners : {
load : function(records, options)
{
console.log( 'loaded ' + records.totalLength + ' records');
},
loadexception: function(proxy, options, response, error)
{
console.log('error loading records from server:');
console.log("\tfile: "+error.fileName);
console.log("\tline: "+error.lineNumber);
}
}
});

using firebux I see that the request it do is a POST...

Any hint?

thanks

666ragez666
7 May 2009, 6:19 PM
The store does not take a method configuration, you have to create the proxy on your own if you want to use get method. Also next time please intent your code properly and put it in CODE tags, see the forum help (http://extjs.com/learn/Ext_Forum_Help) for more reference.:D


var storeRes = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: Data.ServerName + '/resource.xml',
method: 'GET'
}),
id: 'res',
reader: new Ext.data.XmlReader({
record: 'resource',
id: 'id'
},
[{
name: 'name',
type: 'string'
}]),
listeners: {
load: function(records, options) {
console.log('loaded ' + records.totalLength + ' records');
},
loadexception: function(proxy, options, response, error) {
console.log('error loading records from server:');
console.log("\tfile: " + error.fileName);
console.log("\tline: " + error.lineNumber);
}
}
});

silvyivy
8 May 2009, 1:18 AM
Thank's a lot, sorry for the code... I'm new...:)
I'll remembet it for the next time, thank's again!

666ragez666
9 May 2009, 4:46 AM
No problem, I hope you will enjoy using ext js as we do!