将JSON对象发布到PHP [英] post JSON object to PHP
本文介绍了将JSON对象发布到PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我有一个巨大的javascript对象,我想将其传递给PHP.
so i have a gigantic javascript object that i want to pass it on to PHP.
我正在尝试的是: -使用stringify将其作为隐藏字段的值 -点击提交
What i'm trying is: - use stringify to put it as the value of a hidden field - hit submit
在PHP中,如果我
echo $_POST['hidden']
JSON字符串看起来很完美, 但是当我使用
the JSON string seems perfect, but when i use
json_decode($_POST['hidden'])
我得到NULL
如果我使用jQuery的
If i use jQuery's
$.post
,我得到的正是预期的结果:我能够在上面使用json_decode.
, i get exactly the desired result: i am able to use json_decode on it.
有人可以向我解释我做错了什么吗? 谢谢
Can someone explain to me what i'm doing wrong? thanks
推荐答案
也许您需要进行urldecode? http://php.net/manual/en/function.urldecode.php
Maybe you need to do urldecode? http://php.net/manual/en/function.urldecode.php
这篇关于将JSON对象发布到PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文