Recently learned Angularjs, found using its own $http.post back to PHP to send data, PHP received the problem. Like what:
$http. Post ("php/getroleright.php", {rr: $scope. Currselect}). Success (function (response) {·});
PHP usage
$_post[' RR ']
Cannot receive the passed-over parameters.
Open Firebug found actually success, tossing the long time only found that it is only the format of transmission and ordinary transmission format such as the $.post () method in jquery, the format of the transmission, $http. Post () is transmitted in JSON format, and $.post () is transmitted as a form parameter, while PHP $. Post[] is expected to receive the data transmitted from the foreground in the form of the latter, so it cannot read JSON data.
Surfing the internet and adding your own experiments, there are two ways to solve this problem:
1. Simple and rude directly to the $.post () method, so that the background does not make any changes, but online some more experienced netizens said this may violate the original intention of using angular.
2. Modify the PHP code
$postData = file_get_contents (' Php://input ', true); $obj =json_decode ($postData); $query 1 = "SELECT * FROM Role_roleright WHERE roleid= $obj->rr ";
The JSON string is read first and parsed into an object so that the value of the parameter RR passed in is taken from the object's properties.
All right, it's done.
The above describes the Angularjs in the $httppost data to the PHP receive problems, including the angularjs aspects of the content, I hope that the PHP tutorial interested in a friend helpful.