gpt4 book ai didi

php - 发布的值显示在 Firebug 中,但在尝试访问它时显示空白数组

转载 作者:搜寻专家 更新时间:2023-10-31 21:05:04 24 4
gpt4 key购买 nike

  1. 我已经使用 angualr js 开发了一个用于 crud 操作的迷你应用程序我在发送帖子请求时面临问题,它显示了发布的值(value)在 fireug 控制台中,如图 1 所示,但同时尝试使用相同的方法$_REQUEST 或 $_POST 返回空白数组

解释..

在 product.js 中

app.controller('productsCtrl',function($scope,Data){ 
$scope.changeStatus=function(product){
$scope.status = {};
$scope.status.status = product.status=='Active' ? 'Inactive' : 'Active';
//Data.put('http://localhost/angularCrud/products.php',$scope.status);
Data.put('http://localhost/angularCrud/test.php',$scope.status);
};
});

在 data.js 中

app.factory('Data',['$http','$location',function($http){ 
var obj={};
obj.put=function(q,param){ //console.log(data);
//$http.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
successData = $http.post(q,param).success(function(response){
console.log(response);
return response;
});
};

return obj;
}]);

enter image description here

enter image description here

请告诉我如何访问状态的发布值??

最佳答案

我的应用程序也遇到了同样的问题。我的解决方案是

$data = file_get_contents("php://input");  //Get all data of form
$request = json_decode($data);

$request 是一个对象数组,现在可以这样使用

$request->action  //Anything your data is

关于php - 发布的值显示在 Firebug 中,但在尝试访问它时显示空白数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33992614/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com