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