Home > Web Front-end > JS Tutorial > Implement jquery to load data immediately on the startup page

Implement jquery to load data immediately on the startup page

php中世界最好的语言
Release: 2018-03-15 10:03:32
Original
2318 people have browsed it

This time I will bring you how to implement jquery to load data immediately on the startup page, and implement jquery to load data immediately on the startup page. What are the precautions?The following is a practical case, let's take a look.

In fact, the important thing is this method:

$(document).ready(function(){ 
}
Copy after login

Specifically in jquery:

For specific how to use ajax, you can check out my last blog "A brief discussion of ajax requests in jquery and responses in 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="&#39;+ data[i][&#39;orderId&#39;] +&#39;">未处理</a>';
 	 		}else if( status == -1 || status == -2){
 	 		strA = '<a class="m2" value="&#39;+ data[i][&#39;orderId&#39;] +&#39;">已接受</a>';
 	 		}else if( status == -3){
 	 		strA = '<a class="m3" value="&#39;+ data[i][&#39;orderId&#39;] +&#39;">已完成</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>
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

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to the php Chinese website Other related articles!

Recommended reading:

Realize the linkage effect between the input box and the drop-down box

##Use jquery to operate the text content of the input box

The above is the detailed content of Implement jquery to load data immediately on the startup page. 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