时间:2021-07-17 08:10:10 | 栏目:jquery | 点击:次
其实,重要的就是这个方法:
$(document).ready(function(){ }
具体的在jquery中:
具体的ajax怎么使用,可以查看我的上一篇博客《浅谈ajax在jquery中的请求和servlet中的响应》
<script type="text/javascript"> $(document).ready(function(){ var str = ""; var strA = ""; $.ajax({ type: "GET", url: "<%=path%>" + "/queryOrder.do", dataType: "json", async:false, data:{ }, success: function(data){ for (var i in data) { var num = parseInt(i) + 1; var status = data[i]['status']; if( status == 0 || status == -4){ strA = '<a class="m1" value="'+ data[i]['orderId'] +'">未处理</a>'; }else if( status == -1 || status == -2){ strA = '<a class="m2" value="'+ data[i]['orderId'] +'">已接受</a>'; }else if( status == -3){ strA = '<a class="m3" value="'+ data[i]['orderId'] +'">已完成</a>'; } str +="<tr><td>" + num + "</td><td>" + data[i]['ownerName'] + "</td><td>" + data[i]['telephone'] + "</td><td>" + data[i]['hopeTimeName'] + "</td><td>" + data[i]['build'] + "</td><td>" + data[i]['description'] + "</td><td>" + strA + "</td>"; + "</tr>"; } $(".tabletr").after(str); }, error: function(data){ } }) }); </script>
在jsp中:
<div class="tab-pane active" id="A" style="text-align:center;"> <div class="row marg" > <h3>维修单</h3> <table border="2 " style="width:100%;text-align:center;"> <tr class="tabletr"> <th>序号</th> <th>业主名</th> <th>联系方式</th> <th>时间</th> <th>地址</th> <th>项目描述</th> <th>状态</th> </tr> </table> </div> </div>