码迷,mamicode.com
首页 > Web开发 > 详细

ajax取json数据——简单的

时间:2015-01-22 15:23:27      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:

 

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>

 

  

ajax取json数据——简单的

标签:

原文地址:http://www.cnblogs.com/wanliyuan/p/4241548.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!