Q:

Best format to submit an autocomplete?

I'm seeking advice on best practice when submitting a varying number of POST variables.
Do I use JSON or some character separated list to merge all the values into one field or use a sequence of fields like 'autocomplete1', 'autocomplete2' and so on.
Does jQuery have a json encoder?
Thanks in advance,
Ben

A:

It depends on what you are doing with the data you eventually merge.  We often use a form field array 
(ex. < input type="text" name="fieldName[]" > < input type="checkbox" name="fieldName[]" value="true" >).  This will put all your form fields into an array when accessing after a submit.  You can then use a server-side language like PHP to parse the array and do whatever you want with it.
If you need separate field names, you could always name the form fields with separate names and then merge them server-side with something like:
foreach( $_POST as $p=>$v )
{
   $arrayFields[$p] = $v;
}

If this is strictly client-side, I would just increment the needed fields and have a standard field name, followed by "_1" , "_2", etc.  You could easily merge them client-side or server side as needed.
I am not sure about JSON capabilities that would help here.

