My M*EAN app is supposed to return data to the Angular side from the database using php, but when the controller runs and the $http.get executes, response.data returns the source code of index.html instead.
I think all the code necessary to help us find the bug is below. There are also some screenshots of what's going on when the app is run in Chrome using the developer tools, so that you know exactly what I'm talking about.
We are running on a MAMP server, and I know that our app is running on the Apache server, but we don't know why we still aren't getting the JSON data, but the HTML is sent as a JSON response.
Here's the accompanying code:
market.php
<?php
header("Access-Control-Allow-Origin: *");
include 'dbConfig.php';
$sel = mysqli_query($con,"select * from Chef");
if (!$sel) {
printf("Error: %s\n", mysqli_error($con));
exit();
}
$data = array();
while ($row = mysqli_fetch_array($sel)) {
$point = array("fullname"=>$row["fullname"],"city"=>$row["city"],"state"=>$row["state"],"zip_code"=>$row["zip_code"],"rating"=>$row["rating"]);
array_push($data, $point);
}
header('Content-type: application/json; charset=utf-8');
echo json_encode($data);
marketControllers.js
angular.module('OrchidApp')
.controller('marketController', function ($scope, $http) {
console.log('ANYTHING');
$scope.users=[];
$http({method: 'GET', url:'market.php', headers:{ 'X-Force-Content-Type': 'application/json' }})
.then(function successCallback(response) {
$scope.users = response.data;
console.log($scope.users);
console.log("There is data here.");
return $scope.users;
}, function errorCallback(response) {
console.log(response.data);
console.log("Error.");
});
});
index.html
<!doctype html>
<html lang="en" ng-app="OrchidApp" >
<head>
<title>Orchid</title>
<meta charset="utf-8">
<base href="/">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.3/angular.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.3/angular-cookies.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.4.2/angular-ui-router.min.js"></script>
<script src="/js/app.js"></script>
<script src="/js/authService.js"></script>
<script src="/js/profileController.js"></script>
<script src="/js/marketControllers.js"></script>
<script src="/js/navController.js"></script>
<script src="/js/loginController.js"></script>
<script src="/js/signupController.js"></script>
</head>
<body class="container">
<div ng-controller="marketController">
<p>Above the table.</p>
<table>
<tr ng-repeat="user in users track by $index">
<td>{{user.fullname}}</td>
<td>{{user.city}}</td>
<td>{{user.state}}</td>
<td>{{user.zip_code}}</td>
<td>{{user.rating}}</td>
</tr>
</table>
<p>Below the table.</p>
</div>
</body>
</html>
Screenshots:


