title: AngularJs http get to PHP script returns the php code
body: <p>I am trying to grab an echo from a php script that spits out JSON.</p>
  
  <pre><code>&lt;?php
      $arr = array('a' =&gt; 1, 'b' =&gt; 2, 'c' =&gt; 3, 'd' =&gt; 4, 'e' =&gt; 5);
      echo json_encode($arr);
  ?&gt;
  </code></pre>
  
  <p>What I have in my angular code is the following: 
  'use strict';</p>
  
  <pre><code>app.factory('HttpRequestService', function($http) {
    var HttpRequestService = {
      async: function() {
  
        var promise = $http.get('/test.php').then(function (response) {
          return response.data;
        });
        return promise;
      },
      load: function() {
          console.log('helloo');
      }
    };
    return HttpRequestService;
  });
  </code></pre>
  
  <p>And then in my service I have :</p>
  
  <pre><code>HttpRequestService.async().then(function(data) {
      console.log('data is : ' + data);
  });
  </code></pre>
  
  <p>but this literary spits the whole php script and not just the echo data:</p>
  
  <pre><code>console :
  data is : &lt;?php
      $arr = array('a' =&gt; 1, 'b' =&gt; 2, 'c' =&gt; 3, 'd' =&gt; 4, 'e' =&gt; 5);
      echo json_encode($arr);
  ?&gt; 
  </code></pre>
  
  <p>Any ideas why this is happening? Thanks!</p>