Answer the question
In order to leave comments, you need to log in
How to accept object in php in this case?
I have jquery code:
var wizard_object = JSON.stringify(newThemeWizard);
$.ajax({
type : 'POST',
url : 'index.php',
data: "data="+wizard_object,
success: function(res){
console.log(res);
}
});
var_dump(json_decode($_POST['data'], true));
Answer the question
In order to leave comments, you need to log in
$a = json_decode($_POST['data']);
var_dump ($a->someproperty);
Discover the joy of abstractions over requests/responses. Avoid superglobals, use HttpKernel (or your own implementation). Pass json to the POST Body in general, and on the PHP side do json_encode for php://input (if we have Content-type: application/json in the request headers).
Learn to do things right.
js:
$.post("index.php", { data: newThemeWizard }, function(resp) {
console.log(res);
});
$data = json_decode($_POST['data']);
$data->some_property; //получаем данные
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question