Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何将ajax post的序列化日期与数组合并?_Php_Ajax_Jquery - Fatal编程技术网

Php 如何将ajax post的序列化日期与数组合并?

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] ) 我该怎么做

如何使用jqueryforajaxpost将序列化日期与数组合并

比如说,

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)
很高兴听到这个:)