【发布时间】:2012-08-10 19:03:01
【问题描述】:
我在我的网站上使用 CORS 进行跨域对话。虽然图片中显示的响应标头对我来说似乎很好,但是我没有收到任何响应。它仍然是空白或返回响应。任何人都可以通过查看附件图像来预测我的方法中的错误吗?
在服务器端,我正在使用这个 sn-p
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Credentials: true ");
header("Access-Control-Allow-Methods: GET, POST");
header("Access-Control-Allow-Headers: Content-Type, Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control");
在客户端,我有:-
function getXMLHTTPRequest() {
try {
req = new XMLHttpRequest();
} catch(err1) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch (err2) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch (err3) {
req = false;
}
}
}
return req;
}
var http899 = getXMLHTTPRequest();
http899.open("GET", modurl, true);
http899.setRequestHeader('Content-Type', 'text/html');
http899.onreadystatechange = useHttpResponse899;
http899.send(null);
【问题讨论】:
-
请看一下过期时间。它是 1981 年的。这会是个问题吗?
-
这里似乎有类似的问题:serverfault.com/questions/446152/…
-
@JoeCoderGuy 在解决了我的问题之后,我写了这篇文章。查看stackoverflow.com/questions/11964178/…
标签: http http-headers xmlhttprequest cross-domain cors