【发布时间】:2011-08-13 23:59:20
【问题描述】:
我正在使用 jQuery 将 json 对象发布到我的 php 应用程序。
jQuery.post("save.php",JSON.stringify(dataToSend), function(data){ alert(data); });
从 firebug 中提取的 json 字符串如下所示
{ "data" : [ { "contents" : "This is some content",
"selector" : "DIV.subhead"
},
{ "contents" : "some other content",
"selector" : "LI:nth-child(1) A"
}
],
"page" : "about_us.php"
}
在 php 中我试图把它变成一个关联数组。
到目前为止我的php代码是
<?php
$value = json_decode(stripcslashes($_POST));
echo $value['page'];
?>
对 ajax 调用的响应应该是“about_us.php”,但它返回空白。
【问题讨论】:
标签: php json post http-post associative-array