i want to send a jquery object to a php function using post my object comes in then i stringify it and get the following output
[
{
"id": "701",
"user_id": "2",
"playlist": "ukg%20garage",
"tracks": "5",
"thumbnail": "Coldplay.jpeg",
"createdon": "2012-08-23 16:06:46"
}
]
so i then pass this thru with post as below
var sendData = JSON.stringify(data, null, 2);
console.log(sendData);
$.post('<?php echo base_url(); ?>account_media/updateplaylistpicture', sendData, function(response) {
console.log(response);
});
and with my php i am doing a print_r($_POST) but its returning nothing
Array
(
)
Where am i going wrong thanks
UPDATE I MANAGED TO SUSS IT WITH THE BELOW
var sendData = JSON.stringify(data, null, 2);
var sendData = sendData.replace(/[\[\]']+/g,'');
$.post('<?php echo base_url(); ?>account_media/updateplaylistpicture', jQuery.parseJSON(sendData), function(response) {
console.log(response);
});
That is very likely because the POST does not contain any “key”.
Try this:
Another way would be to: