I'm trying to loop through an un-ordered list with form fields in each. When I try to append it to formdata and process it through PHP it just returns
team: "[object Object],[object Object]"
JS is here:
var arr = [];
$( '#team_list li' ).each(function(idx, li) {
$team_name = $( li ).find('input[name="team_name"]').val();
$team_role = $( li ).find('input[name="team_role"]').val();
$team_citizen = $( li ).find('#country').val();
$team_status = $( li ).find('#id_team_status').val();
arr.push({ name: $team_name, role: $team_role, citizen: $team_citizen, status: $team_status, });
});
fd.append('team', arr );
fd.append('team:', JSON.stringify(arr) );otherwise you need elements to pass the values into. Say you have a div to display$team_nameyou would need to do something like this:<div class="team-name">'+arr.name+'</div>countryandid_team_statusids. Ids are expected to be unique per document