Pass list from Jquery to form I have an AJAX form that I've created into a block exposed on my current page. I will have an interface that will allow the users to select an indefinite amount of content to be used within the submit function of the form.

All the variables that will be passed to my form are node ID numbers, but there could be 1, there could be 50.

I have the Jquery action ready to update my ID numbers but I don't know how to get my ID number from Jquery into a variable, which can then be read when the AJAX form is submitted.

I've been looking at this - How to pass Javascript variable with form on submit?

and this - How to trigger a form and pass variables to $form_state with jQuery?

And I've been looking at the responses to both, but neither seem to give me access to the data I need, or are only speaking about a single variable, I need to pass a list or an array.

Would it be best to write something to trigger the form rebuild when I provide a new ID and allow the ID to be written into the form via that method?
For anyone looking to an answer to this, it really depends on whether or not you're working with an AJAX form or not. Ideally I wanted to avoid just populating a text area with my updated field to be submitted, so thankfully, since it was using the AJAX form, I was able to pass it information dynamically through Jquery. 

In your javascript

// whatever your function is to get the information you want to pass
....
Drupal.ajax['edit-save'].options.data._my_vars = JSON.stringify(myList);

// Where 'edit-save' is the ID of my save button in my form
// you can console.log(Drupal.ajax) to see what options you have


Then in the callback for your AJAX request, the return request is stored in

$form_state['input']['_my_vars'] // or whatever variable name you passed above


Then you can check whether or not the response has comeback empty by using

 if (empty(json_decode($form_state['input']['_my_vars']))) {
   form_set_error('save'); // You can set the error to be any form element
 }


and in your callback code you can make your own error handling by doing

if (form_get_error() !== null) { 
  // fail code
} else {
  // success code
}


Hope this helps someone else down the line