List in params with Nested Dynamic form

Name your form fields target_0[], target_1[] etc. (note the opening and closing square bracket in the names). Then you have to make sure that your JS simply appends target_0[], target_1[] etc. to the form dynamically.

Example: assuming your JS builds form parameters like so (note the seemingly incorrect order):

target_0[]=1
target_1[]=4
target_1[]=5
target_1[]=6
target_0[]=2
target_0[]=3

Then this will result in this HTTP POST payload:

target_0[]=1&target_1[]=4&target_1[]=5&target_1[]=6&target_0[]=2&target_0[]=3

Which on the server will be read as:

%{"target_0" => ["1", "2", "3"], "target_1" => ["4", "5", "6"]}

In short, you can construct list form fields. It’s not exactly standard but a lot of frameworks support it (Phoenix / Plug included) and all major browsers allow it as well.