I need to pass a Javascript array of objects to PHP. Found about 3 solutions on the internet, but none of them worked for me. The array looks like this (in Chrome dev console):
And my current AJAX call looks like this:
function consolidate() {
var studentsstring = JSON.stringify(students);
$.ajax({
type: "POST",
url: "writefile.php",
dataType: "json",
data: {students: students},
success: function(data) {
alert(data);
}
});
}
And the PHP file looks like this:
<?php
print($_POST['students']);
?>
Currently, when I hit the "consolidate" button, nothing happens. No alert is shown. Chrome dev reports no errors in the code.