Home >Web Front-end >JS Tutorial >How to automatically load data with jquery
Below I will share with you an example of jquery automatically loading data when starting the page. It has a good reference value and I hope it will be helpful to everyone.
In fact, the important thing is this method:
$(document).ready(function(){ }
Specifically in jquery:
How to use ajax specifically, you can check out my last blog "A brief discussion of ajax requests in jquery and responses in servlets"
<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>
In jsp:
<p class="tab-pane active" id="A" style="text-align:center;"> <p 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> </p> </p>
The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.
Related articles:
What are the application scenarios of child processes in Node.js
Detailed interpretation of the file system and related issues in nodeJs Stream
What are the Javascript debugging commands?
The above is the detailed content of How to automatically load data with jquery. For more information, please follow other related articles on the PHP Chinese website!