JavaScript variable empty without previous alert messge
问题 I'm using the following function to create a list of links from a JSON-File and put them into a span element (jquery has been initialized) $(document).ready(function() { function createjson(category) { var content = ""; i = 0; $.getJSON(category + ".txt", function(data){ while(data[i] != null) { content = content + '<li class="liste"><a target="_blank" class="liste" href="' + data[i].url + '">' + data[i].name + '</a></li>'; i++; } }); document.getElementById("list_" + category).innerHTML =