Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何从离子角柱中获取变量?_Php_Angularjs_Cordova_Ionic Framework - Fatal编程技术网

Php 如何从离子角柱中获取变量?

Php 如何从离子角柱中获取变量?,php,angularjs,cordova,ionic-framework,Php,Angularjs,Cordova,Ionic Framework,从我的后端服务器,我无法从ionic angular post从$\u post获取数据 下面是我的代码: $scope.formData = {}; $scope.processForm = function(){ $http({ type: 'POST', url: 'http://domain/contact', dataType: 'jsonp', headers: { 'Content-Type': "application/x-ww

从我的后端服务器,我无法从ionic angular post从$\u post获取数据

下面是我的代码:

$scope.formData = {};

$scope.processForm = function(){


  $http({
    type: 'POST',
    url: 'http://domain/contact',
    dataType: 'jsonp',
    headers: {
     'Content-Type': "application/x-www-form-urlencoded"
   },
    data: {
      _method: 'POST',
      name: $scope.formData.name,
      email: $scope.formData.email,
      subject: $scope.formData.subject,
      message: $scope.formData.message
    } //pass data as string

  })
    .success(function(data){
         //callback
    });

};

变量:名称、电子邮件、主题和电子邮件无法传递到后端

遵循这种格式,它应该可以正常工作。我这样做是为了我的离子应用。只需将您的数据数组声明为普通var数据并将其发送到post即可。您不需要仅为http方法包含数据的方法类型

$scope.processform = function(){
       var registerdata = {PleaId:$sessionStorage.pleaId, DefenderId:contactid,IsFaceOffUser:'YES'};
            $http({
                method: 'POST', url: 'http://apple.com:9090/Plea/UpdatePleaDefendant', 
                data: registerdata})
               .success(function (data, status, headers, config) {
                //whatever you want after success function
               }).error(function (data, status, headers, config) {
                console.log("http error:", data);
              });
}

将类型“POST”替换为方法“POST”…更改后,我在控制台上收到此错误:NetworkError:405方法不允许在$http内发送数据..是的,它确实在标头后的内部。