I’ve been stuck on this for quite a long time now. I can’t figure out what’s wrong, and I am getting nowhere. I would really appreciate some advise!
Problem:
- Instead of the json result (ex: {“a”:1,“b”:2,“c”:3}) I get the whole php file ( I know this because in the index.html file, I tested it with {{ items }} )
- When I load the php file instead of the index.html, I see json though
- The HTTP status of the php file is 302 also…
- I’ve tried putting the Context-type: application/json in the php file and setting cache to false
app.js
.controller('EntryController', ["$scope", "$http", function($scope, $http) { $scope.items = []; $http({ method: 'GET', cache: false, url: '../services/getItemtest.php' }) .then(function(response) { $scope.items = response.data; }, function(response){ $scope.items = 'Could not retrieve Items'; }); ...
getItemtest.php
<?php header("Content-Type: application/json"); $result = array('a'=>1, 'b'=>2, 'c'=>3); echo json_encode($result); ?>