[英]Fill up array of a Javascript-File by using other file
I have a js-file(A) including an array 我有一个包含数组的js文件(A)
$(function(){
function initVMap(){
$('#vmap').vectorMap({
map: 'world_mill',
//...........................
markers: [
{latLng: [3.2, 73.22], name: 'Maldives'},
{latLng: [35.88, 14.5], name: 'Malta'},
{latLng: [12.05, -61.75], name: 'Grenada'},
{latLng: [13.16, -59.55], name: 'Barbados'},
{latLng: [17.11, -61.85], name: 'Antigua and Barbuda'},
{latLng: [-4.61, 55.45], name: 'Seychelles'},
{latLng: [7.35, 134.46], name: 'Palau'},
]
});
}
//........................
the array data will be provided by another system and changes constantly. 阵列数据将由另一个系统提供并不断变化。 So, the idea is to provide array-data out of the other json-file(B). 因此,该想法是从另一个json-file(B)中提供数组数据。 My question is. 我的问题是。 Could somebody tell me if and how to call the other file(B) to fill up the array of my json-file(A)? 有人可以告诉我是否以及如何调用另一个文件(B)来填充我的json文件(A)的数组吗?
I probably have a solution. 我可能有解决方案。
I will write my array data to a json-file(FileB). 我将数组数据写入json-file(FileB)。 In my js-File(A) i will call the date in (FileB) like: 在我的js-File(A)中,我将在(FileB)中调用日期,例如:
var myList;
$.getJSON('json-file.json')
.done(function (data) {
myList = data;
});
But how to insert "myList" into my array of js-File(A)? 但是,如何将“ myList”插入到我的js-File(A)数组中?
markers: [
{latLng: [3.2, 73.22], name: 'Maldives'},
{latLng: [35.88, 14.5], name: 'Malta'},
{latLng: [12.05, -61.75], name: 'Grenada'},
{latLng: [13.16, -59.55], name: 'Barbados'},
{latLng: [17.11, -61.85], name: 'Antigua and Barbuda'},
{latLng: [-4.61, 55.45], name: 'Seychelles'},
{latLng: [7.35, 134.46], name: 'Palau'},
]
});
}
Can somebody help me? 有人可以帮我吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.