在跨域調用的IE中,Jquery $ .ajax失敗我正在使用跨域請求$.ajax。它適用于Firefox和Chrome,但不會在IE 7或8上發出呼叫。任何人都可以告訴我以下內容有什么問題嗎?我使用了JSON和JSONP(由于一些自定義限制,我停止使用它)。我已經Allow-access-control-origin在我的網站上使用標題了。(沒有這些,Chrome和Firefox沒有成功請求。)我已經嘗試過https://developer.mozilla.org/en/http_access_control碼:$.ajax({
type: 'GET',
url: "http://anotherdomain.com/Service/GetControl?id=" + zoneID,
cache: false,
contentType: "application/x-www-form-urlencoded",
async: false,
beforeSend: function (request) {
//alert('before send');
//request.setRequestHeader("X-Requested-With", "XMLHttpRequest");
//request.setRequestHeader("X-PINGOTHER", "pingpong");
} ,
success: function (data, status) {
//alert("Data returned :" + data);
//alert("Status :" + status);
if (status == "success" && data != "")
$("#" + div.id).append(data);
else
$("#" + div.id).attr("style", "display:none;");
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus);
alert(errorThrown);
}});我嘗試了多個網站上的各種提示,但還沒有運氣。
3 回答

四季花海
TA貢獻1811條經驗 獲得超5個贊
只需安裝這個jQuery插件:用于IE8的jQuery跨域AJAX
這個1.4kb的插件可以立即在Internet Explorer 8和9中運行。
在jQuery之后包含插件,并正常調用你的ajax請求。沒有其他要求。
插件GitHub repo和安裝說明
- 3 回答
- 0 關注
- 504 瀏覽
添加回答
舉報
0/150
提交
取消