I am trying to send a HTTP GET request to a remote server and use the response on an HTML page. Below is the project/js/script.js page
var app = angular.module('app', ['ngResource']);
var config = {
url:"www.myWebsite.com/discover",
headers: {
"X-Object-Header" : "123456789 ",
"Content-Type": "application/json"
}
};
app.controller('discoverObjectCtrl', ['$scope', '$http', function (scope, http) {
console.log('Everything Works!');
http.get("/object", config).success(function (data) {
scope.object = data;
});
console.log(scope.object);
}]);
In my response header, this is what I get
Remote Address:127.0.0.1:63342
Request URL:localhost:63342/object
Request Method:GET
Status Code:404 Not Found
Request Headers
Accept:application/json, text/plain, /
Accept-Encoding: gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Host:localhost:63342
Referer: localhost:63342/DemoSP/index.html
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36
X-Object-Header: 123456789
What I would like to do is send the http request with a customized URL. So for instance I would like my console Header to display
Request URL:www.myWebsite.com/discover/object
And not
Request URL:localhost:63342/project/www.myWebsite.com/discover/object
Please I need Help on this. Thanks
`XMLHttpRequest cannot load https://www.myWebsite.com/discover/object. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.` So how do I set `Access-Control-Allow-origin headers` – AllJs Aug 03 '14 at 23:19