In the below code, for each staff member I am trying to grab a list of the group_ids of groups they supervise and then I want to stringify the array containing those ids and send it off to update the database.
However, when I try to stringify the mapped array, I get an error about converting a circular structure. I don't quite see what is circular in the below code.
Any help is much appreciated.
$(".staff_member").each(function() {
var staff_id = $(this).attr("staff_id");
var newarr = $(this).find(".staff_groups .staff_group").map(function() {
return $(this).attr("group_id");
});
alert(JSON.stringify(newarr));
$.post(
"staff_update.php",
{ staff_id: staff_id, groups: newarr },
function(data) {
var response = jQuery.parseJSON(data);
if(response.code == "success") {
alert("Done!");
} else if(response.code == "failure") {
alert("Failure!");
}
}
);
});
console.log(newarr)