Javascript 存储动态多维数组
动态多维数组的形式如下:Javascript 存储动态多维数组,javascript,Javascript,动态多维数组的形式如下: coordinates:"[75.07760579,29.93068379]" 来自一些API调用 现在如果有10个不同的坐标,我想将每10个坐标存储到数组中,比如说latitude=[]和Longitude=[] Lattude将由75.07760579组成 经度将为29.93068379 有人能帮忙吗 我是这样做的: $.ajax({ async: false, type: "GET", dataType: "json", cont
coordinates:"[75.07760579,29.93068379]"
来自一些API调用
现在如果有10个不同的坐标,我想将每10个坐标存储到数组中,比如说latitude=[]
和Longitude=[]
Lattude将由75.07760579组成
经度将为29.93068379
有人能帮忙吗
我是这样做的:
$.ajax({
async: false,
type: "GET",
dataType: "json",
contentType: "application/json",
header: header,
url: '../../api/..../' + ouid + '.json?fields=[coordinates]',
success: function (response) {
var coordinates = response.coordinates;
lattitude.push.apply(coordinates);
},
error: function (response) {
}
});
//您将在AJAX响应“RESPONSE.coordinates”中看到您的案例
var响应={
坐标:“[75.07760579,29.93068379]”
};
变量纬度=[],经度=[];
var coordinates=JSON.parse(response.coordinates);
纬度推(坐标[0]);
经度推(坐标[0]);
console.log(纬度、经度)
您能在这里发布多个坐标示例吗?假设我调用api 10次,那么10个不同的坐标将如下所示:假设我调用api 10次,那么10个不同的坐标将如下所示:坐标:“[65.0760579,29.93068379]”坐标:[43.07760579,35.93068379]“坐标:”[67.07760579,12.93068379]“……JSON.parse(坐标);latitude.push(坐标[0])longitude.push(坐标[1]),并将纬度和经度作为全局数组