I have a textarea where a user can enter 1 or more emails on there, each email separated by comma.
My js code:
var emails = $("#emails").val().split(",");
if (emails.length == 0)
{
window.alert("Enter an email address.");
$("#emails").focus();
return;
}
var valid = validateEmails(emails);
var goodEmails = valid[0];
var badEmails = valid[1];
var json = JSON.stringify(goodEmails);
$.ajax
({
url: "/mfa/service/initiate_user",
type: "POST",
data: {"emails" : json},
The data I see:
["yao@a.com","yao@b.com]
What I was hoping for:
yao@a.com, yao@b.com
The way I would handle it in the backend is basically stripping out the "[ ]" from it then stripping out the quotes from each email.
What is the proper way to send the emails to backend without those silly brackets and quotes?