我正在使用jQuery将json对象发布到我的php应用程序.
jQuery.post("save.php",JSON.stringify(dataToSend), function(data){ alert(data); });
Run Code Online (Sandbox Code Playgroud)
从萤火虫中拉出的json字符串看起来像这样
{ "data" : [ { "contents" : "This is some content",
"selector" : "DIV.subhead"
},
{ "contents" : "some other content",
"selector" : "LI:nth-child(1) A"
}
],
"page" : "about_us.php"
}
Run Code Online (Sandbox Code Playgroud)
在PHP中我试图将其转换为关联数组.
到目前为止,我的PHP代码是
<?php
$value = json_decode(stripcslashes($_POST));
echo $value['page'];
?>
Run Code Online (Sandbox Code Playgroud)
对ajax调用的响应应为"about_us.php",但它返回空白.