I\'m trying to add a key value pair to an existing javascript associative array. The key needs to be a variable. This is for JSON encoding. I realize there are many plugins
var ary = []; function pushToAry(name, val) { var obj = {}; obj[name] = val; ary.push(obj); } pushToAry("myName", "myVal");
Having just fully read your question though, all you need is the following
$(your collection of form els).serializeArray();
Good old jQuery