我有一个Javascript数组,我想添加到提交表单时数组数组。除了已经从表单发布的其他变量之外,还应该添加Javascript数组。有没有办法在JQuery中做到这一点?添加一个Javascript数组到表单POST提交变量
Ex。
形式:
<form id="my-form" action="/create.php" method="post">
<input id="first_name" type="text" />
<input id="last_name" type="text" />
</form>
Javascript数组:
<script type="text/javascript">
var external_ids = [{"name":"SSN","value":"555-55-5555"},
{"name":"PID","value":"GBNT22"}];
</script>
这是我希望得到的PHP $ _POST阵列的样子,如果可能的话:
Array
(
[first_name] => John
[last_name] => Smith
[external_ids]=>
(
[SSN] => 555-55-5555
[PID] => GBNT22
)
)
看到这一点: http://stackoverflow.com/questions/3322632/is-it-possible-to-submit-javascript-array-along-with-form-submission – haroonxml