PDA

View Full Version : Getting back json property from save



Anthony.Hall
30 Apr 2012, 1:28 AM
I have the following save request. I'm trying to get back the json property "Message". If i write 'data.Message' i am return undefined. How to i get this value.

Here is the json i am returned.

{"TotalCount":"1","Message":"This job number is invalid","DeliveryNoteDetails":[]}




record.save({
success: function (data) {
Ext.MessageBox.alert('Status', 'Changes saved successfully.' + data.Message);
},
callback: function (data) {

Ext.MessageBox.alert('Status', 'callback' + data.Message);
},
failure: function (data) {


Ext.MessageBox.alert('Status', 'Changes could not be saved' + data.Message);
}
});

vietits
30 Apr 2012, 2:08 AM
Try this


record.save({
success: function (data, operation) {
var message = 'failure';
if(operation.response){
var response = Ext.decode(operation.response.responseText) || {};
message = response.message;
}
Ext.MessageBox.alert('Status', 'Changes saved successfully.' + message);
},
callback: function (data, operation) {
var message = 'failure';
if(operation.response){
var response = Ext.decode(operation.response.responseText) || {};
message = response.message;
}
Ext.MessageBox.alert('Status', 'callback ' + message);
},
failure: function (data, operation) {
Ext.MessageBox.alert('Status', 'Changes could not be saved');
}
});