Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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

share|improve this question
 
Use firebug to see what the server returns to your application, it might differ from what you get in the browser. –  devmiles.com Oct 18 '13 at 9:49
 
Ok, in Firebug, I click on Net tab and I see all response is under XHR tab. When I click on one of the response, it is is same as before: size is correct 31 bytes in Headers tab. I see that in the Response tab, nothing present. Is this means my data is not received by my app? Thanks –  bonchenko Oct 18 '13 at 10:01
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.