0
我有一個很大的問題,我 做了一個小的應用程序離子,angularjs,如果沒有錯誤, 工作當我添加$http.get()
呼叫接收JSON文件 瀏覽器顯示錯誤:
XMLHttpRequest cannot load ..... No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access.
$http.get("http://elite-schedule.net/api/leaguedata")
.success(function(data) {
deferred.resolve(data);
}) .error(function() {
console.log("Error while making HTTP call.");
deferred.reject();
});
我添加擴展Allow-Control-Allow-Origin: *
和應用程序返回運行 但我在我的手機(安卓)的問題不顯示任何 我認爲我們應該讓這種訴求$ http.get
請,誰知道在手機顯示的console.log(),就知道誰早已這個錯誤
錯誤的來源或謝謝很多
我對這個錯誤信息感到困惑。你想向「http:// localhost:8100」或「http:// elite-schedule.net」發出請求嗎? – Michael
使用jsonp insted的json.check下面的鏈接http://stackoverflow.com/questions/6396623/jquery-getjson-access-control-allow-origin-issue – sarath
因爲你正在開發一個混合應用程序,你最終可能會移動到科爾多瓦。看看白名單:https://cordova.apache.org/docs/en/4.0.0/guide_appdev_whitelist_index.md.html –