Salve, io ho un array di array che vorrei trasferire tramite ajax in un file php per poi stamparlo in un file txt. Il codice che ho usato è il seguente:
JAVASCRIPT
function saveData(){
//dataString e' un array di array
var jsonString = JSON.stringify(dataString);
$.ajax({
type: "GET",
url: "script.php",
data: {data : jsonString},
cache: false,
success: function(){
alert("OK");
}
});
}
PHP
<?php
$data = json_decode($_GET['data']);
file_put_contents('filename.txt', print_r($data, true));
?>
Dove sbaglio?