Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
sharepoint 2010 restful调用出现angularjs跨域错误_Angularjs_Rest_Sharepoint - Fatal编程技术网

sharepoint 2010 restful调用出现angularjs跨域错误

sharepoint 2010 restful调用出现angularjs跨域错误,angularjs,rest,sharepoint,Angularjs,Rest,Sharepoint,我正在通过Angular JS调用restful sharepoint 2010服务,如下所示,但当我运行应用程序时,我始终会得到“请求的资源上不存在“访问控制允许源代码”标题。因此,不允许访问源代码“null”。错误。 注意:如果我通过Chrome POSTMAN工具从本地机器尝试相同的GET方法,则相同的调用也会起作用。我做错了什么 var myApp = angular.module('MyApp', []); myApp.config(function($httpProvider) {

我正在通过Angular JS调用restful sharepoint 2010服务,如下所示,但当我运行应用程序时,我始终会得到“请求的资源上不存在“访问控制允许源代码”标题。因此,不允许访问源代码“null”。错误。 注意:如果我通过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";
  });
});

您在本地IIS上有本地网站吗?你用什么浏览器?尝试IE。想法是,它将是一个客户端单页应用程序,可以访问sharepoint场,还将具有一些脱机功能。因此,一旦我得到数据,客户端上的所有代码都会显示出来。我试过IE,同样的代码也在工作。但我很好奇为什么同样的请求适用于Chrome Postman,而不适用于我的代码?安全问题。在Chrome(和Firefox)上,您不能执行REST来请求来自资源来源域之外的另一个域。您可以允许此GET请求,但不允许POST请求。顺便说一下,我也有同样的问题,我还在寻找答案。邮递员工作,因为呼叫不是来自浏览器,而是来自程序。