Php 如何将ajax post的序列化日期与数组合并?
如何使用jqueryforajaxpost将序列化日期与数组合并 比如说,Php 如何将ajax post的序列化日期与数组合并?,php,ajax,jquery,Php,Ajax,Jquery,如何使用jqueryforajaxpost将序列化日期与数组合并 比如说, var array = { name: "John", time: "2pm" }; $.post( "page.php", $("form").serialize() + array); 我明白了 Array ( [url] => another test [page_id] => 140 [method] => update[object Object] ) 我该怎么做
var array = { name: "John", time: "2pm" };
$.post( "page.php", $("form").serialize() + array);
我明白了
Array
(
[url] => another test
[page_id] => 140
[method] => update[object Object]
)
我该怎么做才能合并它们并得到下面的结果
Array
(
[url] => another test
[page_id] => 140
[method] => update
[name] => John
[time] => 2pm
)
用于序列化数组/对象
var array = { name: "John", time: "2pm" };
$.post( "page.php", $("form").serialize() + '&' + $.param(array));
在表单中使用隐藏字段
name
和time
,并使用您希望的值初始化它们。js的扩展功能:请记住,在客户端,您的var数组
不是数组,而是对象。您可以简单地循环一个对象的属性并将它们添加到第二个对象,请参见“谢谢”,但我只得到这个数组([name]=>John[time]=>2pm)
很高兴听到这个:)