-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.js
More file actions
25 lines (20 loc) · 728 Bytes
/
init.js
File metadata and controls
25 lines (20 loc) · 728 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
let fileList = ['nodeList.json', 'linkList.json'];
function loadJSON(fileName, callback) {
var xobj = new XMLHttpRequest();
xobj.overrideMimeType("application/json");
xobj.open('GET', fileName, false); // synchronous loading
xobj.onreadystatechange = function () {
if (xobj.readyState == 4 && xobj.status == "200") {
callback(JSON.parse(xobj.responseText));
}
};
xobj.send(null);
}
let extractedArrays = [];
fileList.forEach(element => {
loadJSON(element, function(json) {
console.log(`${element} has been loaded.`); // this will log out the json object
extractedArrays.push(json);
});
});
console.log(extractedArrays);