@gabnastya

Добрый день! Как считать данные из json файла объекты nodesArray и edgesArray и записать их в элементы js nodesArray и edgesArray? через ajax запрос?

var nodesArray = [];
        var edgesArray = [];
    ]
            $.getJSON("file.json",function (data) {
                   
                    for(var i=0;i<data.nodesArray.length;i++){
                        nodesArray.append(('nodesArray').append(data.nodesArray[i].id + data.nodesArray[i].label));
                            console.log(data.nodesArray[i].id);
        }
           });


"file.json"

{"nodesArray":[{"id":20,"label":"http:\/\/ido.isu.ru\/ru\/institut\/doc.html"},{"id":21,"label":"http:\/\/ido.isu.ru\/ru\/contacts\/chema.html"},{"id":19,"label":"http:\/\/ido.isu.ru\/ru\/contacts\/contact.html"},{"id":1,"label":"http:\/\/ido.isu.ru\/ru\/index.html"},{"id":17,"label":"http:\/\/ido.isu.ru\/ru\/staff\/documenti\/index.html"},{"id":31,"label":"http:\/\/ido.isu.ru\/ru\/images\/Skulptura"},{"id":8,"label":"http:\/\/ido.isu.ru\/ru\/institut\/index.html"},{"id":12,"label":"http:\/\/ido.isu.ru\/ru\/education\/PP\/"},{"id":37,"label":"http:\/\/ido.isu.ru\/ru\/announces\/announceitem.html?action=show&id=1295"},{"id":44,"label":"http:\/\/ido.isu.ru\/ru\/staff\/teacher\/"},{"id":7,"label":"http:\/\/ido.isu.ru\/ru\/"},
{"id":29,"label":"http:\/\/ido.isu.ru\/ru\/announces\/announceitem.html?action=show&id=1153"}],"
edgesArray":[{"arrows":"to","from":20,"to":20},{"arrows":"to","from":20,"to":3},{"arrows":"to","from":20,"to":21},{"arrows":"to","from":20,"to":19},{"arrows":"to","from":20,"to":7},{"arrows":"to","from":20,"to":9},{"arrows":"to","from":20,"to":1},{"arrows":"to","from":20,"to":8},{"arrows":"to","from":20,"to":2},{"arrows":"to","from":20,"to":10},{"arrows":"to","from":20,"to":11},{"arrows":"to","from":20,"to":5},{"arrows":"to","from":20,"to":6},{"arrows":"to","from":20,"to":14},{"arrows":"to","from":20,"to":13},{"arrows":"to","from":20,"to":4},{"arrows":"to","from":20,"to":16},{"arrows":"to","from":36,"to":20},{"arrows":"to","from":36,"to":3},{"arrows":"to","from":36,"to":21},{"arrows":"to","from":36,"to":19},{"arrows":"to","from":36,"to":7},{"arrows":"to","from":36,"to":1},{"arrows":"to","from":36,"to":23},
  • Вопрос задан
  • 18 просмотров
Пригласить эксперта
Ответы на вопрос 1
lidacriss
@lidacriss
wtf
Такое?
var nodesArray = [];
var edgesArray = [];
$.getJSON("file.json", function(json){
	nodesArray = json.nodesArray;
	edgesArray = json.edgesArray;
});
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы