PDA

View Full Version : 3.3.0 jsonstore res.message is undefined



arsenepark
2 Dec 2010, 9:01 PM
Hi, there,

The following is my extjs-3.3.0 JsonStore code and the server response, "res.message" is always "undefined", any idea? If I use extjs-3.0.0, everything is fine.

Thanks.
Dennis

This is my js code:



var store = new Ext.data.JsonStore({
autoSave: false,
method: 'post',
proxy: new Ext.data.HttpProxy({
api: {
read: 'admin-json/userlist.jspx',
update: 'admin-json/userupdate.jspx',
create: 'admin-json/useradd.jspx',
destroy: 'admin-json/userremove.jspx'
},
method: 'post'
}),
fields: this.userBean,
writer: new Ext.data.JsonWriter({
encode: true,
writeAllFields: true
}),
idProperty: 'id',
totalProperty: 'count',
root: 'users',
triggerAction: 'all',
listeners: {
beforeload: {
fn: function(store, options) {
}
},
load: {
fn: function(store, records, options) {
}
},
write: function(store, action, result, res, rs) {
// alert(res.message); // undefined, why???
if (action == Ext.data.Api.actions.create) {
action = 'create';
} else if (action == Ext.data.Api.actions.update) {
action = 'update';
} else if (action == Ext.data.Api.actions.destroy) {
action = 'destroy';
} else {
action = 'operation';
}
if (res.success) {
app.setAlert('Msg', action + 'success');
} else {
app.setAlert('Msg', action + 'fail');
}
},
exception: function(proxy, type, action, options, res, arg) {
app.setAlert('Msg', 'exception');
}
}
});


This is my server response:

{"count":1,"message":"success!","success":true,"users":[{"id":8,"lastlogintime":null,"lastlogintimestr":"","password":"fffff","username":"f"}]}

Condor
3 Dec 2010, 3:24 AM
It would if you would have configured your JsonReader with messageProperty:'message'.

('res' is not the raw data, it's the return value from reader.readResponse)