外部JS文件可以规避同源策略吗?

发布于 2024-11-15 03:28:12 字数 165 浏览 11 评论 0原文

我目前正在创建一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

草莓味的萝莉 2024-11-22 03:28:12

该策略很简单,是同域策略,因此,您应该不会有问题。例如,大多数网站管理员从 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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文