Origin XX is not allowed by Access-Control-Allow-Origin.
其實就是 js 跨域訪問問題
什麼引起了ajax不能跨域請求的問題?
ajax本身實際上是通過XMLHttpRequest對象來進行數據的交互,而瀏覽器出於安全考慮,不允許js代碼進行跨域操作,所以會警告。
解決方法 紅色是重點的地方。
function Sel() {
$.ajax({
url: "",
type: "GET",
dataType: 'jsonp',
timeout: 5000,
success: function (json) {
alert(json);
},
error: function (xhr, ajaxOptions, thrownError){ alert("Http status: " + xhr.status + " " + xhr.statusText + "\najaxOptions: " + ajaxOptions + "\nthrownError:"+thrownError + "\n" +xhr.responseText); } });
}