I am trying to pass a simple jquery array with ajax, and when I use a var_dump in php it shows null, but when I show the output through jquery the array appears.
Jquery
aux = ['ahsja', 'shjdshjd', 'dh8f8sfs8'];
var json = JSON.stringify(aux);
$.ajax({
type: "POST",
url: "test.php",
dataType: 'json',
data: {date: json},
success: function (res) {
window.open(this.url, '_blank');
console.log(JSON.stringify(res));
},
error: function (res) {
console.log(JSON.stringify(res));
window.open(this.url, '_blank');
}
});
PHP
$date= json_decode($_POST['date']);
var_dump($date);