I am trying to use jQuery and Ajax to submit a group of forms. Forms do not always have the same number of inputs or the same names for elements.
The code works fine for what I have, except that the values that the switch is set to. It always returns the value of the last switch.
This is how I get the form data:
var values = {};
var formdata = new FormData();
$('form :input').each(function()
{
formdata.append(this.name, $(this).val());
});
I also tried:
$('form.ajax :input, form.ajax input[type=radio]:checked').each(function()
What is the correct way to get the values of a checked switch? I hope you don’t have to write a separate function for each form that I submit.
source
share