<?php
$db = mysqli_connect('localhost','root','','dbname')
or die('Error connecting to MySQL server.');
$query = "SELECT * FROM tablename";
$result = mysqli_query($db, $query);
header('Content-Type: applicatio`enter code here`n/json');
while($row = mysqli_fetch_row($result)){
echo json_encode($row);
}
?>
<script>
var app = angular.module('mainApp', []);
app.controller('ctrl', function($scope, $http) {
$http.get("file.php").then(function (response) {
var d = JSON.parse(response);
console.log(d);
$scope.answers = response.data.records;
});
});
</script>
Response :- ["1","santosh","1","9"]["2","chandan","2","9"] but in angularjs showing error SyntaxError: Unexpected token [