ajax取json数据——简单的
json数据:json4.json
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <table> <tbody id="tbody1"></tbody> </table> </body> <script src="js/jquery-1.8.3.min.js"></script> <script> $(function(){ $.ajax({ type:"get", url:"js/json4.json", dataType:'json', success:function(ret){ console.log(ret.data); var data = ret.data.items; var totalsize = ret.data.totalsize; var html = ''; for(var i=0;i<totalsize;i++) { html+="<tr>" +"<td>"+data[i]['classId']+"</td>" +"<td>"+data[i]['fullName']+"</td>" +"<td>"+data[i]['groupName']+"</td>" +"<td>"+data[i]['name']+"</td>" +"<td>"+data[i]['number']+"</td>" +"</tr>" } $("#tbody1").html(html); }, error:function(){ } }); }) </script> </html>