我知道由于JavaScript安全沙箱,无法从JavaScript代码所在的域外部加载xml数据.
但是,如果我使用localhost:8080并且xml文档来自同一台机器中的localhost但是来自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 protocol http://store.company.com:81/dir/etc.html Failure Different port http://news.company.com/dir/other.html Failure Different host
来源:JavaScript的同源策略 - MDC,同源策略 - 维基百科.