在AngularJS中,为什么我的帖子数据不被我的php使用?

时间:2015-08-25 18:02:17

标签: php ajax angularjs

我使用以下方式发送一些表单数据:

.controller('signupController',function($scope,$http){

$scope.submitSignup = function(){
    var firstLast = $scope.firstLast;
    var email = $scope.email;
    var phone = $scope.phone;
    var zip = $scope.zip;
    var signup = $scope.signup;

    $http({
        method: 'POST',
        url: '../process.php',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
        },
        data: {
            firstLast:firstLast, 
            email:email, 
            phone:phone, 
            zip:zip
        }
    })
    .then(function(res){
        console.log(res);
    });
}

})

如果我返回查询,我会得到:

data: "INSERT INTO signups (signup_name,email,phone,zip) VALUES ('','','','')"

正如您所看到的,我的值是空的。但是,如果我返回$_POST值,我会得到它为空,如果我打开php错误,我可以得到一条消息,表明我的值是未定义的。

我设置了标头内容类型,它们通常可以避免此问题。

0 个答案:

没有答案