问题描述
我正在寻找解决方案如何使用JSONP在Web Workers中从/到另一个域获取/发送数据。
I am looking for solution how to get/send the data from/to another domain using JSONP in the Web Workers.
由于Web Workers无法访问DOM不可能将< script>
标记与url和回调参数附加到< head> $ c $
Since the Web Workers have not access to the DOM it is not possible to append the <script>
tag with the url and callback parameter to the <head>
tag from Web Workers.
有人知道,如何使用JSONP和Web Workers从/向另一个域获取/发布数据?
Does anybody know, how to get/post the data from/to another domain using JSONP and Web Workers?
感谢,
推荐答案
CORS是一种与JSONP无关的规范过时在较新的浏览器。它可以使用普通的XMLHttpRequest调用启用跨域请求。
CORS is a specification which has nothing to do with JSONP beyond making it obsolete in newer browsers. It enables cross-domain requests using ordinary XMLHttpRequest calls.
这里是它如何工作以及如何使用它。它可用于Firefox 3.5+,Safari 4+,Chrome 3+,Internet Explorer 8+和。
Here's an overview of how it works and how to use it. It can be used in Firefox 3.5+, Safari 4+, Chrome 3+, Internet Explorer 8+, and anything else using one of the same engines.
这篇关于使用JSONP和Web Workers的跨源资源共享(CORS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!