我有以下JSON字符串:
var location= JSON.parse('[{"lat":53.230379427401,"lon":6.5237550480959,"couple":"calvin"},{"lat":53.230386732088,"lon":6.5237666455494,"couple":"calvin"}]');
如果您运行代码,它将给您404错误。我不知道它为什么这样做或怎么做。谁能让我对此有所了解?
我从以下php代码获得了这个JSON字符串:
function getMarkers(){
global $row;
$temp= array();
foreach($row as $marker){
$lon = (string)$marker['latitude'];
$lat = (string)$marker['longitude'];
$couple = (string)$marker['couplename'];
$temp[] = array("lat" => $lat, "lon" => $lon, "couple" =>$couple);
}
echo json_encode($temp,JSON_NUMERIC_CHECK);
}
答案 0 :(得分:4)
位置是指javascript中的“window.location”var,因此它是一个“保留”变量名,使用此var的任何其他名称并将起作用
var currentLocation = JSON.parse('[{"lat":53.230379427401,"lon":6.5237550480959,"couple":"calvin"},{"lat":53.230386732088,"lon":6.5237666455494,"couple":"calvin"}]');