I have a store with a proxy configured to update my database.
proxy: {
type: “ajax”,
api: {
create: MySite.app.BaseURL + ‘Member.php?action=create’,
read: MySite.app.BaseURL + ‘Member.php’,
update: MySite.app.BaseURL + ‘Member.php?action=update’,
destroy: MySite.app.BaseURL + ‘Member.php?action=delete’
},
This all works fine but what I would really like is to be able to read the response so to report to the user success or failure of an update.
For example when an update is successful the json below is returned in the response,
{“success”:true,”message”:”Updated”}
And if not successful then the following is returned,
{“success”:false,”message”:”something terrible happened”}
I’ve tried adding a listener to the store as below but this doesn’t seem to pick up the response.
listeners: {
success: function(response) {
console.log(response);
var data = Ext.JSON.decode(response.responseText.trim());
console.log(data);
if(data.success == 'true') {
console.log('success');
}
}
},
Could anyone help?
Stores don’t fire a success event. That has to be configure in each operation using the success, failure or callback functions.
For example, when you perform a sync, you could do something like this:
Given stores work with bacths, to have to see the batch fields in order to know if it was okay or not.