Origin XX is not allowed by Access-Control-Allow-Origin.解決辦法

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);   } });

    }


詳細說明與其他方法:http://wenku.baidu.com/view/e29f37350b4c2e3f57276386.html



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章