I recently learned angularJS and found the problem that using its own $http.post to send data to the background php, php cannot receive it. For example:
$http.post("php/getRoleRight.php", {rr:$scope.currSelect}).success(function(response) { ·· });
$_POST['rr']
After looking online and doing my own experiments, there are two ways to solve this problem:
1. Simply and crudely change it directly to the $.post() method, so that no modification is used in the background, but some online More experienced netizens said that this may defeat the original intention of using angular.
2. Modify the php code
$postData = file_get_contents('php://input', true); $obj=json_decode($postData); $query1 = "SELECT * FROM role_roleRight WHERE roleId=$obj->rr";
Okay, you’re done.
The above introduces the problem of $httppost in angularJS transmitting data to php for receiving, including the content of angularjs. I hope it will be helpful to friends who are interested in PHP tutorials.