你能告诉我我想要显示的文本是如何出现在HTML中的吗?如果你能帮助我,我会很高兴,这是代码。
*<script>
var xmlhttp = new XMLHttpRequest();
var url = "RoadBikes-Michał_Nowakowski.json";
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var myArr = JSON.parse(this.responseText);
myFunction(myArr);
}
};
xmlhttp.open("GET", url, true);
xmlhttp.send();
function myFunction(arr) {
var out = "";
var i;
console.log(arr.RoadBikes.bike);
for(i = 0; i < arr.RoadBikes.bike.length; i++) {
out += "<li><ul>" +
"<li>Nazwa: " + arr.RoadBikes.bike[i].brand.name1 "</li>"+
"</ul></li>";
}
document.getElementById("tak").innerHTML = out;
}
</script>
*这是我的json document我想只显示RoadBikes-&gt; bike-&gt; brand-&gt; name1