I'm trying to encode and send JSON array to php page and add it to mysql:
var data = $('form').serialize();
$.ajax({
type: 'POST',
url: 'naujas.php',
dataType: 'json',
data: ({
json: JSON.stringify(data)
}),
success: function () {
$('#naujas').load('naujas.php');
}
});
But I think its not working I'm getting response from php like that: pav=1&ppav=2&kiekis=3&kaina=4d&ppav=5&kiekis=6&kaina=7&ppav=8&kiekis=9&kaina=0
php file
<?php
$json = json_decode($_POST['json']);
echo $json;
?>
What I'm doing wrong?