从关联数组打印JavaScript对象

What if I want to console.log only one 1(ANY) javaScript object. Currenly it displays all 1000. Please Look at Php and JS files:

Server.php

if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$data = array("coordinates" => array());

$sql = "SELECT Lng, Lat, URL FROM results LIMIT 1000";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
        $data["coordinates"][] = $row;
    }
}
echo json_encode($data);

Index.js

{
$.ajax({
  dataType: "json",
  url: 'server.php',
  //data: [],
  data: {param: ""},
  success: function(data)
  {
    //JSON.parse(data);  
    console.log(data);
  addMarkers(data,map);
  }
});

}

查看全部
doudong2149
doudong2149
2018/07/25 13:11
  • php
  • ajax
  • javascript
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

3个回复