试图将 javascript 对象传递给 php 并收到此错误。我究竟做错了什么?
var address = {};
address.whatever = "asdf";
$.ajax({
type: 'post',
url: '/resources/scripts/php/whatever.php',
data: 'address=' + JSON.stringify(address),
success: function(returnedData){
console.log(returnedData);
},
error: function (xhr, tst, err) {
console.log(err);
},
});
php
$whatever = json_decode($_POST['address']);
echo json_decode($address);
安慰:
null
感谢您的任何见解!