我在我的網站上使用CORS進行跨域通話。雖然,圖片中顯示的響應標題對我來說似乎很好,但我沒有收到任何迴應。它仍然空白或返回響應。任何人都可以預測我的方法中的錯誤,看到附加的圖像?實施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);
請看看到期時間。它的1981年。這可能是一個問題嗎? – 2012-08-14 14:20:42
似乎在這裏類似的問題:http://serverfault.com/questions/446152/litespeed-enable-access-control-allow-origin-no-response-header-on-cors-request – 2012-11-07 16:01:30
@JoeCoderGuy在解決我的問題之後,我寫了這個..檢查出http://stackoverflow.com/questions/11964178/implementing-cross-domain-communication-between-sites-through-cors-using-php-and/11964339#11964339 – 2012-11-08 07:31:53