1👍
Use .join
to concatenate array elements with a separator. And use .map
to extract the email from each element of data
.
success: function(data) {
var mail = data.map(function(el) {
return el.fields.email;
}).join(',');
$("#id_emailaddress").val(email);
}
Source:stackexchange.com