I am trying to do ajax call using AngularJS $http
service by connecting to the RESTful API.
Result I get :
XMLHttpRequest cannot load http://hostname:8080/abc/test. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
I know that i am doing an XMLHttpRequest to a different domain
.So the browser is blocking it as it usually allows a request in the same origin for security reasons.
Requested Code :
$http({
method: 'GET',
cache: true,
url: "http://hostname:8080/abc/test"
}).then(function successCallback(response) {
console.log(response);
}, function errorCallback(response) {
});
I read so many questions on stackoverflow :
No 'Access-Control-Allow-Origin' header is present on the requested resource error
Access-Control-Allow-Origin header
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '…' is therefore not allowed access
But no success. Any immediate help will be highly appreciable. Thanks