从 Ext.data.Store 访问 http 状态代码
我有一个 http API(令人震惊的新技术),它对设置不同响应状态的不同错误做出反应。
问题是 - 在将 Ext.data.Store 与某些 XMLHttpRequest 内部代理一起使用时,处理此状态的最佳方法是什么?据我所知,“加载”事件不会直接传递状态,还有“异常”,最后一个事件实际上在收到 4** 状态时甚至不会触发。
因此,正如我从代码中看到的那样,xhr 实例在 Ext.data.store 中是隐藏的,因此问题也可以表述为“处理低级 xhr 对象的最佳 extjs 实践是什么”。
I have an http API which (shockingly new technique) reacts on different errors setting different response statuses.
The question is - while using Ext.data.Store with some XMLHttpRequest-inside proxy, what is the best way to handle this statuses? As far as I can understand, "load" event does not pass status directly, as well as "exception", and the last one actually doesn't even trigger when 4** status is received.
So, as I can see from code xhr instance is hidden from Ext.data.store, so the question is also can be stated as "What is best extjs practice to handle low-level xhr object".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Ext.data.Store 上没有异常事件。相反,它是 Ext.data.proxy.Server 及其子类(如 Ext.data.proxy.Ajax)定义 异常事件。侦听器接收包含 http 状态的响应对象。
根据您的设置,您可以在商店的代理上注册侦听器,或者 - 如果您的商店使用模型 - 在模型的代理上注册侦听器。
此测试设置在 Chrome 14 和 FF 6 上适用于我:
There is no exception event on Ext.data.Store. Instead, it is Ext.data.proxy.Server and its sub-classes (like Ext.data.proxy.Ajax) that define an exception event. Listeners receive a response object which includes the http status.
Depending on your setup, you can register a listener on the store's proxy, or - if your store uses a model - on the model's proxy.
This test setup worked for me on Chrome 14 and FF 6:
异常事件确实提供了一个
response
对象,该对象具有一个status
属性,其中包含您想要查看的 HTML 状态代码。如果您的异常确实不是由 4** 错误引发的(根据我的经验,这确实会引发),您可以尝试注册一个 ajax 侦听器
:
The exception event does provide a
response
object which has astatus
property containing the HTML status code you want to see.If your exception is indeed not fired by 4** errors (which in my experience do fire) you could try to register an ajax listener instead:
and
使用 extjs 5.1
商店/代理可以访问每个响应 http 代码 &通过侦听“beginprocessresponse”或“endprocessresponse”事件来处理标头。
我很好奇 EventDomain 如何在 Ext.Ajax、Proxy、Reader 和 Store 之间发挥作用。
Using extjs 5.1
The store/proxy can access every response http code & header by listening to 'beginprocessresponse' or 'endprocessresponse' events.
I am curious how EventDomain plays into the mix between Ext.Ajax, Proxy, Reader, and Store.