my JS is creating objects that look like this:

Now I want to post it to a PHP page.
What I tried is this:
var json = JSON.stringify(item_contents);
console.log(json);
jQ.post(
"http://somedomain.com/headlines/save_items/",
json,
function(data){
console.log("Data: ");
console.log(data);
alert("first success");
},
"json"
)
.success(function() {
alert("second success");
})
.error(function(data) {
alert("error: ");
console.log(data);
})
.complete(function() {
alert("complete");
});
…and the output is always an error. I’m using cakePHP..
Any help? TIA!!!
EDIT:
Currently, what i have on my php page is:
echo print_r($_POST);
and im getting a blank or undefined ouput..
If you really want to post json, set variable name.
In php use
echo $_POST['json'];you also may want to just post object itself:
in php use
echo json_encode($_POST);be sure that somedomain.com is the same where js is.