一、Js数组转json格式传输
关键字:JSON.stringify()
var runlist= {
aver_space: "00′00″",
canvarsta: 1,
space_list:[
{dist: 5, totletime: "00:00:00"},
{dist: 10, totletime: "00:00:00"},
{dist: 15, space: totletime: "00:00:00"}
]
}
var runlist= JSON.stringify(runlist);
二、php接收Json传值
关键字:
(1)html_entity_decode()
(2)json_decode($list,true):第二参数一定要设置为true,才能以数组形式使用,否则是object形式
$runlist= $_POST['runlist'];
$runlist= html_entity_decode($runlist);
$runlist= json_decode($runlist, true);
print_r($runlist);