使用JSONP和Web Workers的跨源资源共享(CORS) [英] Cross-Origin Resource Sharing (CORS) using JSONP and Web Workers

查看:215
本文介绍了使用JSONP和Web Workers的跨源资源共享(CORS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找解决方案如何使用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>

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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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