How to retrieve response message in failure function?
store.sync({
success : function(){},
failure : function(response, options){
console.log(response.responseText); //it does not work, because there is responseText attr in response
}
});
Response Text is like this,
{"success":false,"message":"Test Error"}
Anybody know, please advice me.
Thanks
[EDIT]
console.log(response);
then,
I'm not sure if you ever figured this out, but the suggestions above I'm pretty sure are wrong. You need to look at the request exception of the store proxy.
Here is some code to call before you do the store sync.
Ext.Ajax.on('requestexception', function (conn, response, options) {
if (response.status != 200) {
var errorData = Ext.JSON.decode(response.responseText);
Ext.Msg.alert('Creating User Failed',errorData.message);
}
});
Sorry for digging this old post up but it just hurt to see the answers above since I just went through the same struggle.
HTH's.
Here's what you need:
store.sync({
success: function(batch) {
Ext.Msg.alert('Success!', 'Changes saved successfully.');
},
failure: function(batch) {
Ext.Msg.alert("Failed", batch.operations[0].request.scope.reader.jsonData["message"]);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With