jquery ajax

页面载入 加载ajax

1 $(function () { });

2 $(document).ready(function () { });

3 window.onload = function () { }
View Code

 

1.处理json列表的数据

 $.ajax({

        type:'get',
        url: host+"/student/list",
        dataType:'json',
        success:function(res){
            

            for(var i=0; i<res.length; i++){

                var student = res[i];

                var template = "<tr>\n" +
                    "             <td>"+student.id+"</td>\n" +
                    "             <td>"+student.name+"</td>\n" +
                    "             <td>"+student.gender+"</td>\n" +
                    "             <td>"+student.age+"</td>\n" +
                    "\t\t\t <td><span class=\"label label-primary\">编辑</span><span class=\"label label-danger\">  删除</span></td>\n" +
                    "           </tr>"

                $(".table-bordered").append(template);

            }



        }
View Code

 

posted on 2019-04-18 16:46  打酱油的地方  阅读(77)  评论(0编辑  收藏  举报

导航