简体   繁体   English

使用PHP和Jquery将JSON对象发布到服务器

[英]Post a JSON object to server using PHP & Jquery

I have a JSON object: 我有一个JSON对象:

[{"song_id":"17382","title":" Revolution","song_viewed":"6","FK_genre_id":"11","artist_id":"190","artist_name":"Crematory","album_id":"1507","album_name":"Revolution"},{"song_id":"17377","title":"Reign Of Fear","song_viewed":"6","FK_genre_id":"11","artist_id":"190","artist_name":"Crematory","album_id":"1507","album_name":"Revolution"}]

And I want to post this object to server using Jquery.post 我想使用Jquery.post将对象发布到服务器

function postData(dataObj){
  $.post(url,{data:dataObj});
};

in my PHP, I decode this object 在我的PHP中,我解码了这个对象

$dataObj = $_POST['data'];
$dataObj = json_decode($dataObj);

print_r($datObj);

but it looks like it doesn't work. 但看起来不起作用。

Anyone help me? 有人帮我吗?

Could you possibly get any more information before posting it here? 在这里发布之前,您是否可以获得更多信息? Is the script being called? 脚本被调用了吗? Is the array not looking like what you'd like? 阵列看起来不像您想要的吗? It sounds like you're asking us to replicate your setup in order to do debugging for you which you could easily do yourself. 听起来您是在要求我们复制您的设置以便为您进行调试,而您可以轻松地自己进行调试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM