简体   繁体   中英

Post a JSON object to server using PHP & Jquery

I have a JSON object:

[{"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

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

in my PHP, I decode this object

$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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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