-1

I am doing a an ajax get request and I am getting this error:

XMLHttpRequest cannot load http://domains.bootname.com/api/v1/domain/test. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access. 

I am not sure how to get around this... Here is my JS:

var myApp = angular.module('myApp', []);

myApp.controller('mainController', function($scope, $http){
    $scope.message = "hello";

    var myDomain = $scope.myDomain;

    $scope.searchDomain = function(myDomain){
        $http.get('http://domains.bootname.com/api/v1/domain/' + myDomain, {
        type: 'GET',
        dataType: 'JSONP',
        success: function(results){
            console.log(results)
        }
    })
    }

});
fresh5447
  • 1,242
  • 3
  • 14
  • 27

1 Answers1

2

I changed the request to jsonp and added ?callback=JSON_CALLBACK to the end of the URL request..

var myApp = angular.module('myApp', []);

myApp.controller('mainController', function($scope, $http){
    $scope.message = "hello";

    var myDomain = $scope.myDomain;



    $scope.searchDomain = function(myDomain){
        $http.jsonp('http://domains.bootname.com/api/v1/domain/' + myDomain + '?callback=JSON_CALLBACK').then(function(result){
            console.log(result.data);
        });
    }

});
fresh5447
  • 1,242
  • 3
  • 14
  • 27