This is the following code that I am using.
Javascript
<script type="text/javascript">
var stuff = new Object();
stuff[0] = {'id':'0','value':'no','type':'img','filename':'hehehehe.jpg','filesize':'0.3356 MB','fileformat':'jpg','change':'0','caption':'this is a description about the stuff inserted'};
stuff[1] = {'id':'1','value':'yes','type':'img','filename':'hehehehe.jpg','filesize':'0.3356 MB','fileformat':'jpg','change':'0','caption':'this is a description about the stuff inserted'};
stuff[2] = {'id':'2','value':'yes','type':'img','filename':'hsdssssdfhe.jpg','filesize':'0.4356 MB','fileformat':'png','change':'0','caption':'description 2 of the image'};
stuff[3] = {'id':'3','value':'yes','type':'vid','filename':'hehehehe.mp4','filesize':'56 MB','fileformat':'mp4','change':'0','caption':'this is video'};
console.log(stuff);
$.ajax({
type: "POST",
dataType: "json",
url: "test1.php",
data: stuff,
success: function(data){
alert('Items added');
},
error: function(e){
console.log(e.message);
}
});
</script>
test1.php
<?php
$arr = json_decode($_POST['data'], true);
print_r($arr);
?>
The console on Chrome shows the object but php shows undefined.. How can I use the json data in PHP??

newin JS when there is a shorter, more consistent alternative (var stuff = [];orvar stuff = {})