页面载入 加载ajax
1 $(function () { });
2 $(document).ready(function () { });
3 window.onload = function () { }
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> " + " <td>"+student.id+"</td> " + " <td>"+student.name+"</td> " + " <td>"+student.gender+"</td> " + " <td>"+student.age+"</td> " + " <td><span class="label label-primary">编辑</span><span class="label label-danger"> 删除</span></td> " + " </tr>" $(".table-bordered").append(template); } }