gpt4 book ai didi

JavaScript 和 XMLHttpRequest

转载 作者:行者123 更新时间:2023-11-30 09:07:46 24 4
gpt4 key购买 nike

我知道由于 JavaScript 安全沙箱,无法从 JavaScript 代码所在的域外部加载 xml 数据。

但是,如果我使用的是 localhost:8080,并且 xml 文档来自同一台机器上的本地主机,但来自另一个端口,如 8081,这是否被视为同一域?

谢谢

andy e、ken 和 jacob,谢谢大家 :-)

最佳答案

不同的端口被认为是“不同的来源”,因此违反了同源政策。

URL                                                Outcome   Reason=================================================================================http://store.company.com/dir2/other.html           Success   http://store.company.com/dir/inner/another.html    Success   https://store.company.com/secure.html              Failure   Different protocolhttp://store.company.com:81/dir/etc.html           Failure   Different porthttp://news.company.com/dir/other.html             Failure   Different host

来源:Same origin policy for JavaScript - MDC , Same origin policy - Wikipedia .

关于JavaScript 和 XMLHttpRequest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3524790/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com