Home > Web Front-end > JS Tutorial > How to automatically load data with jquery

How to automatically load data with jquery

亚连
Release: 2018-06-11 10:25:54
Original
2323 people have browsed it

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(){ 
}
Copy after login

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][&#39;status&#39;];
 	 		if( status == 0 || status == -4){
 	 		strA = &#39;<a class="m1" value="&#39;+ data[i][&#39;orderId&#39;] +&#39;">未处理</a>&#39;;
 	 		}else if( status == -1 || status == -2){
 	 		strA = &#39;<a class="m2" value="&#39;+ data[i][&#39;orderId&#39;] +&#39;">已接受</a>&#39;;
 	 		}else if( status == -3){
 	 		strA = &#39;<a class="m3" value="&#39;+ data[i][&#39;orderId&#39;] +&#39;">已完成</a>&#39;;
 	 		}
 	 		str +="<tr><td>" + num + "</td><td>" 
 	 			+ data[i][&#39;ownerName&#39;] + "</td><td>"
 	 			 + data[i][&#39;telephone&#39;] + "</td><td>" 
 	 			+ data[i][&#39;hopeTimeName&#39;] + "</td><td>" 
 	 			+ data[i][&#39;build&#39;] + "</td><td>"
 	 			+ data[i][&#39;description&#39;] + "</td><td>"
 	 			+ strA + "</td>";
 	 			+ "</tr>";
 	 	}
 	 		$(".tabletr").after(str);
 	 },
 	 error: function(data){
 	 	
 	 }
 		}) 	
 	});
</script>
Copy after login

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template