You need to grab the input
s for the determined element. You can use .find()
for it.
$( ".vote-form" ).each(function() {
var $this = $(this);
$this.submit(function() {
// get all the inputs into an array.
var $inputs = $this.find(':input');
...
You were grabbing all the existent input
elements and I suspect that because of this during the associative array creation the elements with same this.name
were being overwritten as you were processing the list of matched elements.
By the way, you can drop the .each()
since .submit()
works over the set of matched elements.
Note: I cached $(this)
here.