這是我使用的代碼如向下跌破如下:我使用IE9,但無法看到網絡選項卡發送的請求XDomainRequest在IE正在給訪問被拒絕錯誤
。我有在JSP中設置訪問控制頭:
<% response.setHeader("Access-Control-Allow-Origin", "*");%>
代碼來獲取AJAX HTML從JSP內容:
if ($.browser.msie && window.XDomainRequest) {
var xdr = new window.XDomainRequest();
xdr.open("GET", "http://dev01.org:11110/crs/qw/qw.jsp?&_=" + Math.random());
xdr.contentType = "text/plain";
xdr.timeout = 5000;
xdr.onerror = function() {
console.log('we have an error!');
}
xdr.onprogress = function() {
console.log('this sucks!');
};
xdr.ontimeout = function() {
console.log('it timed out!');
};
xdr.onopen = function() {
console.log('we open the xdomainrequest');
};
xdr.onload = function() {
alert(xdr.responseText);
};
xdr.send(null);
} else { ...... }
我得到一個訪問被拒絕錯誤。任何幫助將非常感激!