ExtJs 6 - 通过成功函数从返回的 JSON 中获取对象

ExtJs 6 - Getting the objects from the returned JSON through the success function

我正在使用 record.erase 删除记录,如果后端出于任何原因无法删除记录,我希望能够显示错误消息。我希望能够显示 JSON 中返回的消息。我想我可以通过 operation 参数来做到这一点,但还没有找到办法。

那么如何从 JSON 访问 "success" 和 "msg"?

控制器

if (record.data.privatePwdsCount === 0)
        Ext.Msg.confirm("Delete", "Are you sure you want to delete this group?", function (id, value) {
            if (id === 'yes') {           
                record.erase({
                    success: function (record, operation) {
                        // check if 'success' is true or false
                        // if true = do nothing
                        // if false = display error msg to user
                    }
                });                  
            }
        });
    else {
        Ext.Msg.alert("Cannot Delete Group", "This group has existing passwords, delete the passwords first to continue");
    }

JSON

"{"success":true,"msg":"Private Group 20 was deleted."}"

自己想出来的,真的很简单 -

var jsonResponse = Ext.decode(operation.getResponse().responseText);
var success = jsonResponse.success;
var msg = jsonResponse.msg;