Angular的XMLHttpRequest无法加载

时间:2015-10-03 18:10:03

标签: javascript angularjs ionic

我正在使用Kimonolabs来刷新我的Ionic应用程序的数据。我刷新时遇到的错误是:

  

XMLHttpRequest无法加载   https://www.kimonolabs.com/api/1z3pta34?apikey=U4SNiysE89aaLXSWRJgHKDZOByqSLM0p&kimindex=1。   请求中不存在“Access-Control-Allow-Origin”标头   资源。因此不允许来源“http://localhost:8100”   访问。

这是我的控制器:

.controller('NCAAFCtrl', function ($scope, NCAAF, $ionicPopup, $ionicLoading) {
  var doGet = function() {

    NCAAF.get().
      success(function (data, gameid) {
        $scope.data = data['results']['collection1'];
        $scope.gameid = data['results']['collection1'][0]['index'];
        console.log(data);
        $ionicLoading.hide();
      }).
      error(function () {
        $ionicLoading.hide();
        var alertPopup = $ionicPopup.alert({
          title: 'Something went wrong',
          template: 'Try reloading in a few seconds.'
        });
        alertPopup.then(function() {
          console.log('Fix this ish');
        });
      }).
       finally(function() {
        $scope.$broadcast('scroll.refreshComplete');
      });
    };
  $scope.doRefresh = function() {
    doGet();
  };

  doGet();
})

和服务:

.service('NCAAF',function($http, $ionicLoading) {
  return {
    get: function() {
      $ionicLoading.show({
        template: 'Loading...',
        delay: 300
      })
      return $http (
      {
        method: 'GET',
        cache: true,
        url: 'https://www.kimonolabs.com/api/[goeshere]&kimindex=1',
        headers: {
              'authorization': 'Bearer [goeshere]'
        }
      });
    }
  };
})

0 个答案:

没有答案