Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/396.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 序列化数组并将其发布到进程文件_Php_Javascript - Fatal编程技术网

Php 序列化数组并将其发布到进程文件

Php 序列化数组并将其发布到进程文件,php,javascript,Php,Javascript,我正在尝试将数组发布到另一个要处理的文件。数组位于下面,它正确填充行。我在脚本标记的开头初始化了它,使其成为全局的。 在javascript中: var locationsall = new Array(); locationsall[counter] = new Array(); locationsall[counter][0] = address; locationsall[counter][1] = lat; locationsall[counter][2] = lng; 在我的表格里,

我正在尝试将数组发布到另一个要处理的文件。数组位于下面,它正确填充行。我在脚本标记的开头初始化了它,使其成为全局的。
在javascript中:

var locationsall = new Array();
locationsall[counter] = new Array();
locationsall[counter][0] = address;
locationsall[counter][1] = lat;
locationsall[counter][2] = lng;
在我的表格里,我试着把它连载并发布

 <input type="hidden" name="result" value="<?php echo serialize($locationsall); ?>">

我做错了什么?

当您通过jQuery更新客户端数据时,需要将result的值设置为您想要传递的值。您可以使用序列化JS对象,这样就可以将JSON编码的数据传递给PHP。处理post数据时,您需要在
$\u post['result']

JS

PHP


输入元素的value属性中显示了什么?当我检查页面源时,显示为value=“N;”。。。不确定这意味着什么该值为空。可以显示表单的更多内容吗?应该更改document.form.result的值是什么?单击第二个单选按钮并添加地址将启动codeAddress()方法,该方法填充locationsall数组
    $locations = unserialize($_POST['result']);
var test = new Array('a', 'b');
var data = $.param(test);
$('#result').val(data);
...
if (isset($_POST['result'])) {
    $data = (array) json_decode($_POST['result']);
}