我正在通过Angular JS调用一个宁静的sharepoint 2010服务,但是当我运行应用程序时,我总是得到“No'Access-Control-Allow-Origin'标头出现在请求的资源上。来源'因此,''不允许访问。“错误。 注意:如果我通过Chrome POSTMAN工具从我的本地计算机尝试相同的GET方法,则相同的调用有效。我究竟做错了什么?
var myApp = angular.module('MyApp', []);
myApp.config(function($httpProvider) {
//Enable cross domain calls
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With'];
});
myApp.controller('MYCtrl', function($scope, $http) {
var site = 'http://inside.company.net/it/gsst/private/_vti_bin/listdata.svc/CCPMGAST';
$http({
method: 'GET',
withCredentials: true,
url: site,
headers: { "Accept": "application/json; odata=verbose" }
}).success(function (data, status, headers, config) {
$scope.getCallJSONResult = data;
}).error(function (data, status, headers, config) {
$scope.getCallJSONResult = "Get error";
});
});