I have a page on which user can dynamically create some identical groups of inputs, fill it and send to server.
<input type='text' name='firstName'/> <input type='text' name='lastName'/>
What is a preferable way of sending this data to server?
Maybe there are some simple ways of emulating hierarhical data over POST request, avoiding XML structures?
Different ‘name’ attribute values (‘firstName1’, ‘firstname2’)?
Creating ID for each group or input?
Relying on the order of name-value pairs in the POST request?
EDIT: Of course i know about JSON. But just to use some minimal hierarchies I would like to follow the second answer: Rely on the order of firstname-lastname in post request.
If the data pairs are ordered, you don’t need additional identifiers as the order already identifies the data pairs. So you could just use
firstNameandlastNamefor every data pair:You server-side application then just combines each data pair.
But some languages/systems already do this when the data has a special format. In PHP you could use the
arg[]syntax to automatically get an array of the data.