[SOLVED] ComboBox JSON
January 6th, 2009
I'm trying to fetch data remotely from a python file to a comboBox, but i'm doing something wrong because its not working.
Here is my code
Ext.onReady(function(){
Ext.QuickTips.init();
// simple array store
var store2 = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'https://somelink.com/data.py?action=something',
}),
reader: new Ext.data.JsonReader({
root: 'myData',
fields: [{name: 'id'}, {name: 'vm'}]
})
});
var combo = new Ext.form.ComboBox({
store: store2,
displayField:'vm',
valueField: 'id',
typeAhead: true,
mode: 'remote',
triggerAction: 'all',
emptyText:'Select...',
selectOnFocus:true,
applyTo: 'someID'
});
The url https://somelink.com/data.py?action=something returns:
{'myData': [{'id': '1', 'vm': 'field1'}, {'id': '2', 'vm': 'field2'}]}
Can anyone help me on this?
Thanks
Needed to add method: 'GET', by default it makes a POST.
It should be like this
proxy: new Ext.data.HttpProxy({
method: 'GET',
url: 'https://somelink.com/data.py?action=something',
}),
After step over...
store: store2
store returns undefined
store2 returns Object data[0]
Firebug doesn't report any specific error, the data just doesn't appear.
tried debugging in firefox? make sure a request is being made, that the json is indeed returning correctly, and no errors are being thrown.
I'm saying this because i have done some tests and thats the way it works for me. If i use mode: 'remote' without method: 'GET' it doesn't work, but it works without method: 'GET' if i set mode to local.
Ext uses GET if there are no params, and POST if there are by default. And if that did make the difference, you werent getting back the correct json to begin with.
#If you have any other info about this subject , Please add it free.# |