javascript 有 jQuery 事件源吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9073947/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a jQuery EventSource?
提问by Phillip Senn
Server Sent Events seem like a prime candidate for a jQuery plug-in. Page 921 of JavaScript, the Definitive Guide shows how to use EventSource. But then page 923 says that IE uses attachEvent instead of addEventListener.
服务器发送事件似乎是 jQuery 插件的主要候选者。JavaScript 的第 921 页,权威指南展示了如何使用 EventSource。但是第 923 页说 IE 使用 attachEvent 而不是 addEventListener。
I found jQuery.EventSourceon github, but there's no mention of attachEvent. It instead falls back to using $.ajax.
我在 github 上找到了jQuery.EventSource,但没有提到 attachEvent。相反,它回退到使用 $.ajax。
Q: If I'm going to use the EventSource feature of JavaScript, should I use jQuery.EventSource?
问:如果我打算使用 JavaScript 的 EventSource 特性,我应该使用 jQuery.EventSource 吗?
I gotta have more jQuery!
我得有更多的jQuery!
回答by karlcow
As of today IE9 doesn't support EventSource (Server Sent Events). In the good article by Remy Sharp, there is at the end of the article a list of polyfill solutions.
截至今天,IE9 不支持 EventSource(服务器发送事件)。在 Remy Sharp 的好文章中,文章末尾有一个polyfill 解决方案列表。