I have a Javascript array that I would like to add to the post array when a form is submitted. The Javascript array should be added in addition to other variables already being posted from the form. Is there a way to do this in JQuery?
Ex.
Form:
<form id="my-form" action="/create.php" method="post">
<input id="first_name" type="text" />
<input id="last_name" type="text" />
</form>
Javascript array:
<script type="text/javascript">
var external_ids = [{"name":"SSN","value":"555-55-5555"},
{"name":"PID","value":"GBNT22"}];
</script>
This is what I would like the resulting PHP $_POST array to look like, if possible:
Array
(
[first_name] => John
[last_name] => Smith
[external_ids]=>
(
[SSN] => 555-55-5555
[PID] => GBNT22
)
)