I am trying to make a http request to my php file. But it returns me the following error
Possibly unhandled rejection: {"data":null,"status":-1,"config":{"method":"GET","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","url":"localhost/sample.php","headers":{"Accept":"application/json, text/plain, /"}},"statusText":"","xhrStatus":"error"}
My angular request is
var some = angular.module("first_module", [])
.controller("first_controller", function($scope, $http, $log) {
$http.get('localhost/sample.php').then(function(response) {
$scope.students = response;
$log.info();
});
});
My PHP file is
<?php
$var2 = new stdClass();
$var2->name = 'john';
$var2->class = '7';
$var2->fee = '45000';
$var2->point = '5';
$response[0] = $var2;
$var2->name = 'ahmed';
$var2->class = '7';
$var2->fee = '55600';
$var2->point = '2';
$response[1] = $var2;
echo json_encode($response);
?>
I am unable to understand the error even. Thanks in advance
UPDATE: on adding an another function for failure and print the log in console I receive the following error
var some = angular.module("first_module", [])
.controller("first_controller", function($scope, $http, $log) {
$http.get('localhost/sample.php').then(function(response) {
$scope.students = response;
$log.info();
}, function(err) {
console.log($log.info);
});
});