I can use some help in here. I am trying to read data from server that returns a text/html response. When I access the url using browser, I would get
220.2,1.2,261.3,221.9,0.1,22.1
where the values are separated by commas. In my controller js, I do
var readEnergy = function() {
$http({method: 'GET', url: var urlEnergy = "http://afternoon-cove-4361.herokuapp.com/meng?", cache: $templateCache }).
success(function(data, status) {
$log.log(status);
$log.log(data);
return data;
}).
error(function(data, status) {
$log.log(data);
return data;
});
$log.log(readEnergy);
$timeout(readEnergy, 2000);
}
$timeout(readEnergy, 2000);
It returns 200 OK, with content-length 30 which is correct to the number of characters in my reponse, using Firefox Inspect Element. But the $log.log(data) and $log.log(readEnergy) returns [object Function] and "", respectively. I expect to be able to get the comma-separated values as string which then I would parse. Thanks for helping me out!
edit: I use
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With'];
to allow cross domain resource sharing as described here