getJSON('http://localhost:63322/logs',function(err, data) { if (err !== null) { alert('Something went wrong: ' + err); } else { //var myObj = JSON.parse(data); // document.getElementById("demo").innerHTML = myObj.ad_soyad;items_table = document.getElementById('items_table');for(var ctr = 0; ctr < data.length; ctr++){ items_table.innerHTML+= '<tr><td>' + data.data[ctr].uid + '</td><td>' +data.data[ctr].ad_soyad + '</td></tr>';} } <form id="form"> <table id='items_table' border=1> <tr><th colspan='2'>liste</th></tr> <tr><th>uid</th><th>ad_soyad</th></tr></table>在这些代码中,我无法显示表格。我的 json 对象没有问题。我可以显示 json 对象,但无法在表格中显示此对象。如何解决此问题?我的 json 对象是{"数据":[{"uid":2,"ad_soyad":"gg"},{"uid":4,"ad_soyad":"gg"},{"uid":4,"ad_soyad":" gg"},{"uid":4,"ad_soyad":"gg"},{"uid":4,"ad_soyad":"gg"},{"uid":4,"ad_soyad":"gg" },{"uid":4,"ad_soyad":"gg"},{"uid":4,"ad_soyad":"gg"},{"uid":4,"ad_soyad":"gg"}, {"uid":4,"ad_soyad":"gg"},{"uid":4,"ad_soyad":"gg"},{"uid":4,"ad_soyad":"gg"},{" uid":4,"ad_soyad":"gg"},{"uid":4,"ad_soyad":"gg"},{"uid":4,"ad_soyad":"gg"},{"uid":4,"ad_soyad":"gg"},{"uid":6,"ad_soyad":"gg"},{"uid":6,"ad_soyad":"gg"},{" uid":10,"ad_soyad":"gg"},{"uid":16,"ad_soyad":"gg"},{"uid":190,"ad_soyad":"gg"},{"uid" :200,"ad_soyad":"gg"},{"uid":200,"ad_soyad":"gg"},{"uid":220,"ad_soyad":"gg"},{"uid":4 ,"ad_soyad":"gg"},{"uid":4,"ad_soyad":"gg"},{"uid":4,"ad_soyad":"gg"},{"uid":4," ad_soyad":"gg"},{"uid":4,"ad_soyad":"gg"},{"uid":4,"ad_soyad":"gg"},{"uid":4,"ad_soyad":"gg"}]}谢谢你的帮助....
1 回答
汪汪一只猫
TA贡献1898条经验 获得超8个赞
这里的问题是data
父对象具有另一个data
作为属性,这data
实际上是这里的数组。所以,你只需要更换:
for(var ctr = 0; ctr < data.length; ctr++)
有了这个:
for(var ctr = 0; ctr < data.data.length; ctr++)
添加回答
举报
0/150
提交
取消