我在我的JavaScript部分写了这个来获取json文件中的数据
$.getJSON("BusStop.json", function(data){
$.each(data, function(i,item){
alert("It can be read");
});
});
这是BusStop.json
[
{ "id":"s01", "name":" ", "longitude":11.603930, "latitide":52.132986},
{ "id":"s02", "name":" ", "longitude":11.609036, "latitide":52.130254},
{ "id":"s03", "name":" ", "longitude":11.608465, "latitide":52.136035},
{ "id":"s04", "name":" ", "longitude":11.580057, "latitide":52.138208},
{ "id":"s05", "name":" ", "longitude":11.590206, "latitide":52.134975},
{ "id":"s06", "name":" ", "longitude":11.584155, "latitide":52.131956},
{ "id":"s07", "name":" ", "longitude":11.591673, "latitide":52.128685},
{ "id":"s08", "name":" ", "longitude":11.620244, "latitide":52.136367},
{ "id":"s09", "name":" ", "longitude":11.612250, "latitide":52.126829},
{ "id":"s10", "name":" ", "longitude":11.597864, "latitide":52.126576}
]
但没有任何反应,我已将json文件更改为BusStop.js,没有任何反应。有谁知道原因?我想将经度和纬度存储在数组中,例如points []。
答案 0 :(得分:0)
最终很容易解决,只需下载一个名为" jquery-3.2.1.min"的文件。 并将此源添加到html。
<script type="text/javascript" src="jquery-3.2.1.min.js"></script>
&#13;