title: AngularJS ajax with PHP json return
body: <p>I am new with php and angularjs >&lt;
  I am trying to using ajax to get the data from php but fail</p>
  
  <p>here's my controller  </p>
  
  <pre><code>angular.module('AA')
      .controller('ExpController', ['$scope', 'Record', '$http', function ($scope,Record, $http) {
      $scope.trans = [];
      $scope.trans = Record.all();
  }]);
  </code></pre>
  
  <p><br/>
  factory.js</p>
  
  <pre><code>    angular.module('AA')
      .factory('Record', ['$http',function RecordFactory($http){
        return{
          all: function(){
              return $http.get("./php/getdata.php").success(function (response) {
                return  response;
              });
          }
        }
  }]);
  </code></pre>
  
  <p><br/>
  ./php/getdata.php</p>
  
  <pre><code>&lt;?php
  header("Content-Type: application/json; charset=UTF-8");
  $response=
        ' [
          {id: 0, title: "help", date: "1288323623009", cost: 20, person:"hard", category:"angu", items:[ {name:"item1"},{name:"item2"},{name:"item3"}]},
          {id: 1, title: "hahah", date: "1288323623008", cost: 9.99, person:"Leo", category:"adv"}
        ]';
  
  echo ($response);
  ?&gt;
  </code></pre>
  
  <p>console said</p>
  
  <blockquote>
    <p>SyntaxError: Unexpected token i<br/>
      at Object.parse (native)<br/>
      at fromJson.....</p>
  </blockquote>
  
  <p>is my json format wrong?</p>