jquery ajax
页面载入 加载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>\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); } }