I'm new here. I wanted to know how can i get code from ajax and use it in php.
<script>
let arrOf = {};
arrOf.name = "Grig";
arrOf.age = 28;
$.ajax({
type : "POST",
url : "insert.inc.php",
data : { arrOf : arrOf },
success: function(res){
console.log("worked");
}
});
</script>
I tried this, but it is wrong.
<?php
$arrOf = $_POST['arrOf']; // Undefined index: arrOf
echo $arrOf ;
?>
I want to have variable like js in php arrOf