I have a controller with service that would get the json from other server and i came to this
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http:somesite.com. This can be fixed by moving the resource to the same domain or enabling CORS.
I notice that some of the same issue would be fix by "Access-Control-Allow-Origin": "*" in header my in my case I don't see any progress on fixing it.
this the code for my controller :
var myApp = angular.module('cplanner',[]);
myApp.controller('GetItemCtrl', ['$scope', '$http', function($scope, $http) {
var itemUrl = 'http:somesite.com';
//console.log(itemUrl);
$http({url: itemUrl,
dataType: 'json',
method: 'POST',
dataType : 'json',
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "POST, GET, OPTIONS, PATCH, DELETE",
"Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept"
},
xhrFields: {
withCredentials: true
}}).success(function(data, status, headers, config) {
//check if the response has ok status
if(data.status == "ok"){
console.log(data.data);
$scope.items = data.data;
}
}).error(function(data, status, headers, config) {
});
}]);
I added the header but it seem not to fix my cross origin issue. Could anyone drive me by any comments and suggestion on how am i able to get the response from another server source. thank you in advance.