So I have a form (dynamically built from selections by the user) and I ran into an "issue" I didnt really think of. I can get the data easy enough with jquery like:
var myForm = document.getElementById('form');
var formData = new FormData(myForm),
data = {};
for (var entry of formData.entries()) {
data[entry[0]] = entry[1];
}
data = JSON.stringify(data)
console.log(data);
$('#json').text(data)
In the console, this produces:
{"form_fullname":"first name last name","form_email":"test@email.com","form_phone":"8885551234","comments":"Justo Lorem Euismod"}
I need to pass this data via an ajax request to a php file that would loop through the data and send it out using phpmailer. I have sucessfully sent form data via ajax before to phpmailer (or just to a php file) many times, but I guess due to the fields being dynamic I am a bit unsure of how to split the data and submit it as something like:
Full Name: $fullName
Email: $fullname
etc etc