AJAX不适用于默认域工作
我有一个AJAX脚本,在主index.php页面,从一个绝对的URL获取数据:'http://www.example.com/ajax
I have an ajax script, in the main index.php page, that fetches data from an absolute URL: 'http://www.example.com/ajax'
现在的问题是,该取的作品,当我从运行 http://www.example.com ,但我只是去 http://example.com ,虽然页面加载蛮好的休息,AJAX脚本赢得T承载。
The problem is that the fetch works when I run it from http://www.example.com, but I just go to http://example.com, though the rest of the page loads just fine, the ajax script won't load.
有谁知道任何可能的原因,这可能是这种情况?
Does anyone know of any possible reason why this may be the case?
在同源策略运行在主机名的基础上,而不是域的基础。
The same origin policy operates on a hostname basis, not a domain basis.
使用相对URI,或者选择一个主机名,作为典型的和重定向所有流量从一个到另一个。
Use relative URIs, or pick one hostname as canonical and redirect all traffic from one to the other.