dongzi1397 2017-03-18 23:27
浏览 36

我没有收到带有angularJS的变量$ _POST

i am starting to angularJS and i make a program to learn but i don't understand why i don't receive my $_POST variable when i sent

this my controller code

var ModalInstanceCtrl = function($scope,$http, $modalInstance, $modal, Name, Country, City) {

     $scope.Name = Name;
     $scope.City = City;
     $scope.Country = Country;



     $scope.ok = function (Name,Country,City) {

         Country = 'test';

       $http.post('requete.php', Country)
            .success(function (reponse) {
                $scope.PostDataResponse = reponse;
            })
            .error(function (status) {
           alert(status);
                $scope.ResponseDetails = "Data";
            });
      };

     $scope.cancel = function () {
        $modalInstance.dismiss('cancel');
      };
}

and this is my requete.php

<?php
header("Content-Type: application/json; charset=UTF-8");
var_dump($_POST);

echo 1;
?>

modal.html

<div class="modal-dialog">
  <div class="modal-content">
    <div class="modal-header-info">
      <button type="button" class="close" ng-click="cancel()"></button>
      <h4 class="modal-title">Envoyer un SMS</h4>
    </div>
    <div class="modal-body">
        {{PostDataResponse}}
        <div class="col-md-12">
        <spam class="spamcenter">Nom : {{Name}}</spam>
        <br>
        <spam class="spamcenter">Pays : {{Country}}</spam>
        <br>
        <spam class="spamcenter">Ville : {{City}}</spam>
        </div>

    </div>
    <div class="modal-footer">
      <button type="button" class="btn btn-default" ng-click="cancel()">Close</button>
      <button type="button" class="btn btn-primary" ng-click="ok(Name,Country,City)">Envoyer</button>
    </div>
  </div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->

and this is my response variable

<?php header("Content-Type: application/json; charset=UTF-8"); var_dump($_POST); echo 1; ?> 

It returns me all the code of my file

i don't understand why and i don't see the trace of my POST in the console network

some one can help me please

thanks in advance

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 msix packaging tool打包问题
    • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线