Ajax跨域错误,但我使用的是同一个域(CORS)

Ajax cross-domain error, but I am using the same domain (CORS)

本文关键字:同一个 CORS 错误 Ajax      更新时间:2023-09-26

我刚开始读一本关于ajax的书。我正在设置一个测试环境,以便在网络上运行代码以测试示例,因为我们讨论的是Ajax。我已经知道Ajax跨域问题,但为什么我得到这个跨域错误?

请求资源的页面的url是:http://diegodesignertest.freeiz.com/teste2.php(我在浏览器中输入的url)

请求是这样执行的:xhr。Open ("get", "http://diegodesignertest.freeiz.com/response.php", true);这段代码包含在test2 .php中,并且正在请求一个response.php文件(这没有意义,我只是在测试)

不是同一个域吗?

我创建了一个xml文件并开始工作。问题是请求一个php文件。

不工作我换了xhr。Open ("get", "http://diegodesignertest.freeiz.com/response.php", true);

工作我换了xhr。Open ("get", "http://diegodesignertest.freeiz.com/response.xml", true);