我要开发一个交互式地图(谷歌地图)。坐标通过 ajax 从 json 解析,但我得到错误
JSON 格式
{"Level":[{"route":[{"lat":39.105251,"lgn":26.551727},
{"lat":39.105247125,"lgn":26.551774625}...],"balls":
[{"lat":39.105239375,"lgn":26.551869875},{"lat":39.10524325,"lgn":26.55182225}]},
{"route":[{........},{.....}...],"balls":[{........},{.....}...]}]}
AJAX 请求
$.ajax({
type: "GET",
url: "getcoordp?q=2",
dataType: "json",
cache: false,
contentType: "application/json",
success: function(data) {
$.each(data.Level, function(i,Level){
$.each(data.route, function(index, route) {
alert(data.lat)
});
});
}
});
错误
Uncaught TypeError: Cannot read property 'length' of undefined
有什么帮助吗?