Я пытаюсь сохранить список значений в массиве, используя $.getJSON, но каким-то образом он не работает, массив показывает undefined в console.log
вот мой код getJSON
jQuery.getJSON(List6.attractionimg, function(rf){
jQuery.each(rf, function(index, file){
attractionImgLinks.push(file.url);
});
Код JSON URL-адрес "List6.attractionimg" дает
{"files":[{"name":"2013-11-17_183243.png","size":7975,"url":"http:\/\/example.com\/demo\/wp-content\/uploads\/rform\/attractionimg\/user5307eb38362d4\/2013-11-17_183243.png","thumbnailUrl":"http:\/\/example.com\/demo\/wp-content\/uploads\/rform\/attractionimg\/user5307eb38362d4\/thumbnail\/2013-11-17_183243.png","deleteUrl":"http:\/\/example.com\/demo\/wp-content\/themes\/driskill\/rform\/files\/attractionimg\/?file=2013-11-17_183243.png","deleteType":"DELETE"}]}
Я объявляю массив вне этого кода, что проблема здесь?
JSON - это объект с свойством files
который содержит массив. Попробуйте связать свойство files
с результатом...
jQuery.getJSON(List6.attractionimg, function(rf){
jQuery.each(rf.files, function(index, file){
attractionImgLinks.push(file.url);
});
Попробуй это
$.each(rf.files,function(index,file){
attractionImgLinks.push(file.url);
})