I am trying to pass a angularjs variable to a php page using http get but not able to access it in the php page. I want to pass a variable and then perform some calculations on that variable in the php page and then retrive it again in the html page. My code looks like:
## HTML$scope.postFunc = function(){
$http.post(
"calculate.php",
{sal:$scope.sal}
).then(function(data){
alert($scope.sal);
$http.get("./calculate.php").then(successCall,errorCall);
});
}
function successCall(response){
$scope.total = response.data;
alert($scope.total);
}
function errorCall(response){
alert("error");
}
PHP File
<?php
$data = json_decode(file_get_contents("php://input"));
$salary = $data->sal;
$da = (20*$salary)/100;
$ta = (30*$salary)/100;
$hra = (60*$salary)/100;
$total_salary = ($salary + $da + $ta + $hra);
echo json_encode($total_salary);
?>
I get an error which says
Trying to get property of non-object in C:\wamp64\www\php\Grade Task\calculate.php on line 3.