I'm trying to pass an array from .js file to a PHP page using ajax post method. would you help me to understand why it is not working?
//js file
$.ajax({
type: "POST",
url: "http://localhost/Project_part3/includes/graph.php",
datatype: 'JSON',
data: {'data1' : JSON.stringify(data1)},
success: function(data){
console.log("success:", data1);
},
failure: function(errMsg) {
console.error("error:",errMsg);
}
});
//PHP page
<?php
$data1 = json_encode($_POST["data1"]);
var_dump ($_POST["data1"]);
?>