Dojo - 拦截XHR呼叫 [英] Dojo - intercepting XHR calls

查看:179
本文介绍了Dojo - 拦截XHR呼叫的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想拦截所有的 dojo.xhr 调用我的应用程序,以检查HTTP响应的内容,然后再将此响应转发给处理函数(加载错误等)。你如何建议这样做?

I would like to intercept all dojo.xhr calls on my application in a way to examine the contents of HTTP response before this response gets forwarded to handler functions (load, error, etc.). How do you suggest to do this?

推荐答案

我相信你要找的是djConfig变量 ioPublish 在1.4中引入。

I believe what you're looking for is the djConfig variable ioPublish introduced in 1.4.

http://dojotoolkit.org/reference-guide/releasenotes/1.4.html#io-pipeline-topics

这将挂接您可以订阅的三个发布主题: / dojo / io / load / dojo / io / error / dojo / io / done ,应该类似于 load 错误 handle 回调。

This hooks up three publish topics you can subscribe to: /dojo/io/load, /dojo/io/error, and /dojo/io/done, which should be analogous to the load, error, and handle callbacks, respectively.

保持请注意,默认情况下,这是因为在每个XHR上发布事件而产生的潜在开销。

Do keep in mind that this is turned off by default precisely because of potential overhead incurred by publishing events on every XHR performed.

这篇关于Dojo - 拦截XHR呼叫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆