0
votes

This is my script

<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
   $http.get("http://ip/ss.php")
   .then(function (response) {$scope.names = response.data.records;});
});
</script>

Help me please

EDIT: This is the exact error

Error: [$http:baddata] Data must be a valid JSON object. Received: "{"records":[{"Time":"ADV 360","Count":"name"},{"Time":"CCE 401","Count":"name"}. Parse error: "{"description":"Invalid character","number":-2146827274,"stack":"SyntaxError: Invalid character\n at fromJson (https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.js:1431:3)\n at defaultHttpResponseTransform (https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.js:11175:11)\n

1
Don't load a minimised angularjs angular.min.js, instead load angular.js and you'll be able to see a clear error - Alon Eitan
are you getting any response from $http request. - abhit
i loaded using angular.js same error.No i didnt get any response that why i am looking to solve this error - Ahmad M Ibrahim
please if someone just can help me - Ahmad M Ibrahim

1 Answers

1
votes

Try to use the following code. This will catch the exact error message in response. Or if you are getting response then check it in console as follows.

    <script>
    app.controller('customersCtrl', function($scope, $http) {
       $http.get("http://ip/ss.php")
       .then(function (response) {
            angular.fromJson(response);
            console.log(JSON.sringify(response));
            $scope.names = response.data.records;},
            function(error) {console.log(JSON.sringify(error));}
       );
    });
    </script>

`