外部JS文件可以规避同源策略吗?
我目前正在创建一个 API,要求用户包含来自我的服务器的外部 javascript 文件。但是,该文件要求调用 AJAX 函数(位于外部 javascript 文件中),该函数从我的服务器提取用户的 API 数据并将其输出到他们的网页上。
我会在同源策略方面遇到麻烦吗? 如果是这样,还有其他选择吗?
I'm currently creating an API that requires the user to include an external javascript file from my server. However, the file requires that it calls an AJAX function (located in the external javascript file) that pulls the user's API data from my server and outputs it on to their webpage.
Will I run into trouble regarding the same-origin policy?
If so, are there any alternatives?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该策略很简单,是同域策略,因此,您应该不会有问题。例如,大多数网站管理员从 Google 的 CDN 加载 jQuery,这是他们应该做的,并且他们仍然使用 jQuery 的 Ajax。希望能回答您的问题! (有时我完全忘记了实际的问题,所以......希望它有帮助)
The policy is simple a same-domain policy, so, you shouldn't have a problem. For example, most webmasters load jQuery from Google's CDN, as they should, and they still use jQuery's Ajax with it. Hope that answers your question! (Sometimes I am completely oblivious to the actual question, so... hope it helps)