当我使用角度js向服务器(codeigniter)发送数据($ _ GET方法)时,我得到空响应

时间:2017-03-29 16:11:56

标签: javascript php jquery angularjs codeigniter

我正在尝试使用角度js向服务器(codeigniter)提交表单数据 我的数据是:

<form>
<div class="form-group">
    <label for="name">First name: </label>
    <input type="text" class="form-control" name="fname" ng-model="fname">
</div>
<div class="form-group">
    <label for="name">Last name: </label>
    <input type="text" class="form-control" name="lname" ng-model="lname">
</div>
<div class="form-group">
    <label for="email">Email</label>
    <input type="text" class="form-control" name="email" ng-model="email">
</div>
<input type="hidden" name="<?=$this->security->get_csrf_token_name();?>" ng-model="csrfData" ng-init="csrfData='<?php echo $this->security->get_csrf_hash();  ?>'" />
<input type="hidden"  ng-model="baseData" ng-init="baseData='<?=base_url();?>'" />
    <div class="form-group row">
    <div class="col-xs-6">
        <a  class="btn btn-block btn-info" ng-click="basicInfoAdd()">
        <span>Next Section </span>
        </a>
        <!--ui-sref="reg.professional"-->       
    </div>
    </div>
</form>

我的角度js控制器代码是

controller("basicInfo",function($scope,$http){
   $scope.new_user = true;
   $scope.basicInfoAdd = function(){
       //alert($scope.baseData);
       $http.get($scope.baseData+"angReg/basicReg/2",{'csrf_test_name':$scope.csrfData,'fname':$scope.fname,'lname':$scope.lname,'email':$scope.email})
       .then(function(response){
                      alert(response.data);
                      })           
       }

我的服务器端代码是

   public function basicReg()
     { 
      $data  = json_decode(file_get_contents("php://input"));
      echo  $clmdata  = $data->fname;

    }

请告诉我我的代码有什么问题......?

0 个答案:

没有答案