私はwebdevに全く新しく、AngularJSを使用する必要があります。 私は本当に$ http.postを使ってトラブルがあります。
app.controller('searchCtrl', function($scope, $http, $log) {
$scope.search = function() {
$http.post('server.php', { "data" : $scope.keywords})
.success(function(data, status) {
$scope.result = data;
})
};
私は(とそれが正常に動作します)このコントローラーを使用しますが、私は$scope.keywords
に加えて、server.php
に2つ目のパラメータ(文字列)を渡したいと思います。
サーバーとクライアントの両方で、どうすればよいですか?
$ http.post( 'server.phpという'、{ "データ":$ scope.keywords、 "anotherData" :anotherData}) –
しかし、server.phpファイルでanotherDataを使用するにはどうすればよいですか? –
サーバ側では、$ _SERVERまたは$ _POST変数にいくつかのパラメータがありますので、そこでチェックしてください。彼らはおそらくjson、json_decode *なのでしょう。 – Astaroth