http://www4.example.com上的页面尝试与http://www6.example.com/建立 xhr 连接 浏览器发送带有此标头的 GET 请求:
Origin: http://www4.example.com
www6.example.com 服务器发回:
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://www4.example.com
Connection: Keep-Alive
Content-Encoding: gzip
Content-Type: text/plain
Date: ...
Keep-Alive: timeout=5, max=100
Transfer-Encoding: Identity
Server: Apache/2.2.20 (Ubuntu)
Vary: Accept-Encoding
X-Powered-By: PHP/5.3.6-13ubuntu3.7
然而我得到:
XMLHttpRequest cannot load http://www6.example.com/myscript.php?xhr=1&t=1234333223. Origin http://www4.example.com is not allowed by Access-Control-Allow-Origin.
我的代码符合我对 CORS 标准的理解,并且适用于 Chrome、Firefox、Opera 等,所以我假设这是 Safari 5.1 的错误?我的问题是我需要做什么来解决它?