我在我的网站上使用 CORS 进行跨域对话。虽然图片中显示的响应标头对我来说似乎很好,但是我没有收到任何响应。它仍然是空白或返回响应。看到附图,谁能预测我的方法中的错误?
在服务器端,我正在使用这个片段
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);