Javascript $http未过帐

Javascript $http未过帐,javascript,php,angularjs,codeigniter,ionic-framework,Javascript,Php,Angularjs,Codeigniter,Ionic Framework,我有一个角度代码,似乎没有张贴。 老实说,firefox显示了发布参数,但当我在服务器上打印($\u POST)并通过firefox查看响应时,我会看到一个空数组 下面是一段代码 $http({ method: 'POST', data : { slotid : slotid }, url: "https://mydomain.abc/Api/reserve_slot/" + slotid + "/" + $scope.do

我有一个角度代码,似乎没有张贴。 老实说,firefox显示了发布参数,但当我在服务器上打印($\u POST)并通过firefox查看响应时,我会看到一个空数组

下面是一段代码

$http({
            method: 'POST',
            data : { slotid : slotid },
            url: "https://mydomain.abc/Api/reserve_slot/" + slotid + "/" + $scope.docid,
            headers: {'Content-Type': 'application/x-www-form-urlencoded'}
        }).then(function successCallback(response) {    
            $scope.r = response.data.list;
            console.log($scope.r);
            if($scope.r.status == 1){

                $scope.hide();
                $state.go('booking', { slotid: slotid });
            }

        });
正在调用url。因为如果我附加了要通过URL传递的变量/值,它们就会工作(很明显)。 我只是不明白为什么这个职位不起作用

我已经测试了
数据:{slotid:slotid},
在slotid中有值

有什么想法吗

-----编辑 下面是完整的控制器代码

.controller('doctorCtrl', ['$scope', '$stateParams', '$http', '$ionicLoading', '$state', // The following is the constructor function for this page's controller. See https://docs.angularjs.org/guide/controller
// You can include any angular dependencies as parameters for this function
// TIP: Access Route Parameters for your page via $stateParams.parameterName
function ($scope, $stateParams, $http, $ionicLoading, $state ) {
    $scope.docid = $stateParams.docid;
    $scope.show = function() {
        $ionicLoading.show({
            content: 'Loading',
            showBackdrop: false,
            animation: 'fade-in',
        }).then(function(){
           console.log("The loading indicator is now displayed");
        });
      };
     $scope.hide = function(){
        $ionicLoading.hide().then(function(){
           console.log("The loading indicator is now hidden");
        });
      };
    $scope.show();
    $http({
        method: 'POST',
        url: "https://mydomain.abc/Api/docinfo",
        data : { docid : $scope.docid },
        headers: {'Content-Type': 'application/x-www-form-urlencoded'}
    }).then(function successCallback(response) {    
        $scope.docinfo = response.data.info;
        console.log($scope.docinfo);
        $scope.loadslots($scope.docid,0);
        //return response.data.list;
    });
    $scope.loadslots = function(docid,dinaya){
        $http({
            method: 'GET',
            url: "https://mydomain.abc/Api/get_slots/" + docid + "/" + dinaya,
            headers: {'Content-Type': 'application/x-www-form-urlencoded'}
        }).then(function successCallback(response) {    
            $scope.slots = response.data.list;
            console.log($scope.slots);
            $scope.hide();
        });
    }
    $scope.showslot = function(slotid){
        $scope.show();
        //data: $.param({slotid: slotid})

        $http({
            method: 'POST',
            //data : { slotid : slotid },
            //data: $.param({slotid: slotid}),
            url: "https://mydomain.abc/Api/reserve_slot/" + slotid + "/" + $scope.docid,
            headers: {'Content-Type': 'application/x-www-form-urlencoded'}
        }).then(function successCallback(response) {    
            $scope.r = response.data.list;
            console.log($scope.r);
            if($scope.r.status == 1){
                $scope.hide();
                $state.go('booking', { slotid: slotid, docid: $scope.docid });
            }

        });
    }

}])
我正在尝试构建一个ionic 1应用程序。尚未在其中添加jquery

添加Codeigniter控制器

public function reserve_slot(){
        /*
        print_r($_POST); //shows me an empty array
        $slot = $this->input->post('slotid); //no data here
        $doc = $this->input->post('doc'); //no data here
        */
        $slot = $this->uri->segment(3);
        $doc = $this->uri->segment(4);
        $this->load->model('Doctor');
        $this->Doctor->reserve_slot($slot);
        $list['status'] = 1;
        $data['list']= $list;
        header("Access-Control-Allow-Origin: *");
        header("Access-Control-Allow-Methods: PUT, GET, POST");
        header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
        header('Content-Type: application/json');
        echo json_encode($data);
    }

原来angular在查询中对$.param也有类似的功能

下面的代码已完成发布

$scope.showslot = function(slotid){
        $scope.show();
        //data: $.param({slotid: slotid})
        var pdata = { slotid : slotid , docid : $scope.docid};
        $http({
            method: 'POST',
            //data : { slotid : slotid },
            data: $httpParamSerializerJQLike(pdata),
            url: "https://mydomain.abc/Api/reserve_slot/" + slotid + "/" + $scope.docid,
            headers: {'Content-Type': 'application/x-www-form-urlencoded'}
        }).then(function successCallback(response) {    
            $scope.r = response.data.list;
            console.log($scope.r);
            if($scope.r.status == 1){
                $scope.hide();
                $state.go('booking', { slotid: slotid, docid: $scope.docid });
            }

        });
    }

我想你需要一个转换函数为你的数据,检查出嗨,我试图添加$.params。但是我得到了下面的错误。ReferenceError:$未定义。我正在用爱奥尼亚试试这个。我需要注入某种依赖关系吗?$意味着您需要jQuery,如果您的项目中没有jQuery,请尝试编写自己的转换函数,如@Ela Buwa中所述,您可以发布控制器的代码吗?@Hekmat hi添加了完整的代码