I tried to JSON.stringify
an array to the server like so:
JavaScript:
jQuery.ajax({
type: 'post',
url: ajax_url,
data: {
'settings' : JSON.stringify([...]),
'action' : [...]
},
traditional: true,
success:function(data) {
alert("SUCCESS");
},
error: function(errorThrown){
console.log(errorThrown);
}
});
But when I tried json_encode
it in PHP it returns NULL
.
PHP
$param = json_decode($test, true);
var_dump($param); //it retuns NULL
And JSON.stringify
array is displayed like this:
{\"uid\":{\"@cdata\":\"6\"},\"board_name\":{\"@cdata\":\"test\"},\"skin\":{\"@cdata\":\"default\"},\"use_comment\":{\"@cdata\":\"\"},\"use_editor\":{\"@cdata\":\"\"},\"created\":{\"@cdata\":\"20160307182421\"}}
What I'm doing wrong?