I am having users fill in a form on page A, I then redirect to page B sending $_POST data with it. I've seen that I can serialize post data from a form like this $("form").serialize()
or this.serialize()
but I don't want to retrieve data from a form I need to get it from $_POST. How do I go about serializing $_POST data not from a form that exists on the current page?
如何从php重定向中序列化ajax中的$ _POST数据
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- douxianliu6756 2016-10-25 18:33关注
I found a solution to this in case anyone else ever wonders how to do this.
var post_info = [];
creates an array to hold all of the $_POST variables. This is what takes all the post variables and puts them into a json array for ajaxpost_info = <?php echo json_encode($_POST); ?>;
. And the ajax looks like normal."ajax": { "url": "ajax/test.php", "type": "POST", "data": {post_info: post_info} },
On the php side I didn't need to json_decode because ajax sends this as a $_POST variable. Except it is now a multidimensional array so accessing variables looks like this
$_POST['post']['item']
. And there you go. I've never answered my own question before.本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 ETLCloud 处理json多层级问题
- ¥15 matlab中使用gurobi时报错
- ¥15 这个主板怎么能扩出一两个sata口
- ¥15 不是,这到底错哪儿了😭
- ¥15 2020长安杯与连接网探
- ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
- ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
- ¥15 可见光定位matlab仿真
- ¥15 arduino 四自由度机械臂
- ¥15 wordpress 产品图片 GIF 没法显示