我試圖通過發送Access-Control-Allow-Origin:*
標題已經允許外部請求的外部域的ajax調用,但我在xmlhttp.post()
行獲得權限被拒絕。IE瀏覽器拒絕AJAX權限?
這裏是我的代碼:
var xmlhttp;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
alert(xmlhttp.responseText);
}
}
xmlhttp.open("GET", "http://www.domain.com", true);
xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xmlhttp.send();
什麼版本的IE? – ceejayoz 2011-01-23 02:50:02
我在IE 8上測試過它 – Ryan 2011-01-23 02:50:40