如何拦截后端额外的响应参数?

问题描述 投票:0回答:1
在商店中添加、更改或删除记录时,我返回

{success: true|false}

。但在某些情况下,我想从后端返回一条附加消息(例如
{success: true, hello: 'world'}
)并将其显示在警报窗口中。但
store write event返回操作,其中只有success
exception
complete
等属性,而
_request
_response
为空。这可能是一个微不足道的任务,但我还没有弄清楚操作对象。如何获取响应以读取其他参数?

javascript extjs
1个回答
0
投票
有多种选择可以实现此目的。

让我们重点关注商店。 这取决于它是代理存储还是缓冲存储。

第一种情况,以加载事件为例。或者,如果它已缓冲,请使用预取事件。

这是一个例子。

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 } } });
    
© www.soinside.com 2019 - 2024. All rights reserved.