JSON字符串化循环结构错误

在下面的代码中,对于每个工作人员,我试图获取他们监督的group_id组的列表,然后我想对包含这些id的数组进行字符串化并将其发送以更新数据库。

但是,当我尝试对映射的数组进行字符串化时,我收到有关转换循环结构的错误。 我不太清楚以下代码中的循环内容。

任何帮助深表感谢。

$(".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!"); } } ); }); 

首先将它转换为数组.. .map()返回一个jQuery对象

 var newarr = $(this).find(".staff_groups .staff_group").map(function() { return $(this).attr("group_id"); }).get() ;