0
我需要使用jQuery AJAX發送跨域請求。但它在IE9中不起作用。IE9中的跨域AJAX無法在CQ5中工作
奇怪的是,當我在獨立的HTML文件中嘗試它時,它工作正常。但在CQ頁面中完成時會中斷。
的JS代碼如下:
$.support.cors = true;
$.ajax({
cache: false,
url: "https://www.some.external.web.service",
dataType: "json",
contentType: "application/json; charset=utf-8",
type: "POST",
crossDomain: true,
data: "{"key":"value"}",
processData: false,
success: function (response) { alert("success"); },
error: function (xhr, status, error) { alert("AJAX Error:status: "+ status+ "\nerror: " + error + "\nxhr.status: " + xhr.status + "\nResponseText: \n" + xhr.responseText); }
});
我一直在使用的數據類型爲 'JSONP',但仍無濟於事嘗試。在IE9中,它永遠不會返回'成功'處理程序,並總是進入'錯誤'處理程序。
顯示的錯誤是'運輸錯誤'。
WebService的是HTTPS和我的網頁可以是HTTP(作者)或HTTP(發佈)
我已經有阿賈克斯前$.support.cors = true;
集。我錯過了什麼?
什麼是錯誤?你是否從https轉到http? – epascarello 2014-11-24 19:00:20
'data:「{key:」+ value +「}」'? (剛剛看到) – l2aelba 2014-11-24 19:01:15
更新了問題。 JSON數據不是問題。錯誤是'Transport Error',服務是https,而我的頁面可以是http或https – 2014-11-24 19:09:21