在 IE8 中使用 XDomain 对象;在 Jquery 中
尽管我已经使用 JQuery 近一年了,但我对 jquery 核心的技能并不是那么好。所以这是问题。
如果我想在 IE8+ 上发出跨域请求时使用 XDomainRequest,我需要做什么更改?
基本上,我想对 jquery.ajaxSettings 对象的 xhr 函数进行更改,以便每当发出跨域请求并且浏览器被检测为 IE8+ 时,xhr 返回 XDR 而不是 XHR。
在这样做之前我需要记住哪些陷阱?
任何人想要提供的任何其他指示都将受到赞赏。
我知道这是一个非常普遍的问题,但从我的感觉来看,在所需场景中用 xdr 替换 xhr 的主题也是如此。
谢谢
my skills with jquery core are not that great, though Ive been working with JQuery for almost a year now.So here is the question.
What changes would I need to do , if I want to use XDomainRequest whenever a cross-domain request is made on IE8+?
Basically, I want to make changes to the xhr function for jquery.ajaxSettings object, so that whenever a cross-domain request is made , and the browser is detected as IE8+, the xhr returns a XDR rather than an XHR.
What all pitfalls would I need to keep in mind before I do that?
Any other pointers that anyone would want to give are appreciated.
I know this as a question is very general, but from what I feel, so is the topic of substituting xhr with xdr in the required scenario.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该尝试 AjaxHook 扩展。
You should try the AjaxHook extension.
JQuery 本身并不支持这一点,但您可以自己解决它。以下是有关此问题的原始 JQuery 错误报告:
http://bugs.jquery.com/ticket/8283
上面的链接有一些解决代码的方法。这是一个更完整的解决方案:
https://github.com/ jaubourg/ajaxHooks/blob/master/src/ajax/xdr.js
JQuery doesn't support this natively, but you can hack around it yourself. Here's the original JQuery bug report about this issue:
http://bugs.jquery.com/ticket/8283
That link above has some work around code. Here is a more complete solution:
https://github.com/jaubourg/ajaxHooks/blob/master/src/ajax/xdr.js