So, as I explained above, I would access (using PHP) an object that I've created using JS and then I've passed to .php by using Ajax. I've heard about json, it can be useful or can I work without that?
I'm linking my code:
var data = {
v_Post: document.getElementById("v_Post").value,
x: document.getElementById("x").value,
y: document.getElementById("y").value,
}
$.ajax({
type: "POST",
url: "http://localhost:80/mySite.it/scripts/script.php",
data: "data=" + data,
dataType: "html",
success: function(v) {
alert("Chiamata riuscita!!!");
},
error: function(){
alert("Chiamata fallita!!!");
}
});
});
});
I've tried to do this in php, but it seems not to work:
$data = $_POST['data'];
echo '<script>console.log($data.v_Post); </script>';
echo $data.v_Post;