{success: true|false}
。但在某些情况下,我想从后端返回一条附加消息(例如
{success: true, hello: 'world'}
)并将其显示在警报窗口中。但store write event返回操作,其中只有
success
、
exception
、
complete
等属性,而
_request
和
_response
为空。这可能是一个微不足道的任务,但我还没有弄清楚操作对象。如何获取响应以读取其他参数?
让我们重点关注商店。 这取决于它是代理存储还是缓冲存储。
第一种情况,以加载事件为例。或者,如果它已缓冲,请使用预取事件。
这是一个例子。
Ext.create('Ext.data.Store', {
proxy, // set properly
listeners: {
load: (store, records, success, operation) => {
let response = operation.getResponse();
// now you can access responseJson or responseText and decode it - depends on your ext version and proxy config
}
}
});