I have a form that had live appended input type hiddens with a name, value, and class and they all mean something. I want to take this and post to my php the json values. So I am doing
var storage = $.param($('form input[type=hidden]').serializeArray(), true);
and that works fine, however it only gets the name, and value. I need the class also because it has a unique id stored in it, which I can’t store in the name or value because those also store unique ids.
So my question/options are.
- Can I somehow store two unique ids in the name that would be processed as such? Maybe a
{id1:1,id2:2}or something as the name value? - Can I make serializeArray also get the class name?
Example of input type hidden I add
<input type="hidden" class="photo_spot_1" name="photo_spot_5" value="../uploads/2462df38db374653720daa42b7aefec4/g6qjcn30kw_c.png">
Notice the two different id’s at the end of name and class.
You cannot have an element id like
{id1:1,id2:2}and alsoserializeArraywill not get the class information from input fields but you can write your own logic to get that.Now you can use
datawhich will contain each hidden input with is name/value and class information.