title: AngularJS get data from MySQL via a php file
body: <p>here's my issue:</p>
  
  <p>I did a very basic angularJS app which is supposed to get data from a php file and bind them into the scope. So the php file (linked to MySQL DB) output is:</p>
  
  <pre><code>[{"hum":"55.36","temp":"20.86","unixtime":"2015-10-29 17:39:42","coreid":"xxxxxx","moist":"0.02","volt":"4.30","soc":"114"},
  {"hum":"55.33","temp":"20.84","unixtime":"2015-10-29 17:39:50","coreid":"xxxxxx","moist":"0.00","volt":"4.30","soc":"114"},
  {"hum":"55.42","temp":"20.84","unixtime":"2015-10-29 17:39:58","coreid":"xxxxxx","moist":"0.02","volt":"4.30","soc":"114"}]
  </code></pre>
  
  <p>The app's code is:</p>
  
  <pre><code>var dashb = angular.module('dashboard', []);
  
  //avoid cross domain issue
  dashb.config(['$httpProvider', function($httpProvider) {
  $http.defaults.useXDomain = true;
  delete $httpProvider.defaults.headers.common['X-Requested-With'];
  }
  ]);
  
  
  dashb.controller('dbCtrl', ['$scope', '$http', function ($scope, $http) {
           $http.get("http://www.domain.com/php_file_url.php")
              .success(function(data) {
                  $scope.data = data;
                  $scope.hum = data.hum;
  
              })
              .error(function() {
                  $scope.data = "error in fetching data";
  
              });
  
  
      }]);
  </code></pre>
  
  <p>But when I run it it doesn't work. I get no data. What do I do wrong? Thank you</p>