1
我有一些jQuery的是獲取數據和執行的回調:
$(function(){
$.ajax({
type: 'POST',
url: 'http://flash-cast-hrd.appspot.com/api/sonar/sync',
data: {
source: 5,
auth: 'JXEI....DHA2J'
},
success: displayData
});
});
我想從我的角度控制器,在那裏我有一個方法上提出同樣的要求範圍。
然後調用它的觀點:
<div ng-init="init()"></div>
當我加載頁面我在控制檯得到一個錯誤:
OPTIONS http://flash-cast-hrd.appspot.com/api/sonar/sync 405 (Method Not Allowed) angular.js:8021
OPTIONS http://flash-cast-hrd.appspot.com/api/sonar/sync No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access. angular.js:8021
XMLHttpRequest cannot load http://flash-cast-hrd.appspot.com/api/sonar/sync. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access. :8000/routes:1
Error is:
我怎樣才能讓角$ HTTP。發佈要求工作?
可能重複此問題http://stackoverflow.com/questions/16661032/http-get-is-not-allowed-by-access-control-allow-origin-but-ajax-is – Vinoth
XMLHttpRequest錯誤可以解決通過在服務器上部署,在部署到服務器後嘗試運行,希望它能工作 – ajitksharma
訪問控制 - 允許來源 – Prashobh