I'm making multiple forms from a script and want to be able to post an associative array of the fieldnames and values using Ajax without needing to know the fieldnames. This seemed like the perfect solution:
Obtain form input fields using jQuery?
However, no matter what I do, when I run var $inputs = $('#myForm :input');
, console.log($inputs)
logs an empty array. I've basically copy-pasted multiple methods from stackoverflow that worked for others, and I consistently have that bug. So I'm wondering if '#myForm :input'
doesn't see the input fields in my case because my form is in a table. If so, how can I build an associative array if my form is formatted this way?
<tr>
<form id='myForm'>
<td><input type='text' name='foo'></td>
...
</form>
</tr>