我想使用IONIC AngularJS将数据插入MYSQL。但是我收到错误“在位置0的JSON中出现了意外的令牌o”
这是app.php的控制器
app.controller('BookingCtrl', function($scope, $http) {
$scope.bookingSave = function(){
$http({
method: 'post',
url: "http://localhost/test/insertDB.php",
data: {
'name' : $scope.nameuser,
'email' : $scope.email,
'phone': $scope.phone,
'type' : 'save_user'
},
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
})
.success(function(data,status,headers,config){
console.log("Data Inserted Successfully");
})
}
});
然后这是insertDB.php
require_once 'conn.php';
$data = json_decode(file_get_contents("php://input"));
$name = $conn->real_escape_string($data->nameuser);
$email = $conn->real_escape_string($data->email);
$phone = $conn->real_escape_string($data->phone);
请帮帮我