html插入数据例子



<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>用户列表demo</title>
		<script type="text/javascript" src="js/jq.js">
		</script>
	<script type="text/javascript">
		$( function(){
		var URL= "http://localhost:8090/getAll"
		var data = ""
		$.get(URL,data,function(data){
		
		
		for (s of data) {
		var tr =`<tr>
			<td>${s.id }</td>
			<td>${s.name }</td>
			<td>${s.age }</td>
			<td>${s.sex }</td>
			
			</tr>`
			$("#table1").append(tr);
		
			
		}
			
		
		});
		
	
	
		} )
	</script>


	</head>
	<body>
		<table id="table1" border="1px" align="center" width="80%">
			<tr>
				<td colspan="4" align="center">
					<h1>用户列表</h1>
				</td>
			</tr>
			<tr>
				<td align="center">编号</td>
				<td align="center">姓名</td>
				<td align="center">年龄</td>
				<td align="center">性别</td>
			</tr>
			<tr>
				<td align="center">100</td>
				<td align="center">黑熊精</td>
				<td align="center">3000</td>
				<td align="center">男</td>
			</tr>
			<h1>作用:获取后端数据 之后也页面展现</h1>
		</table>
	</body>
</html>

 

小青年资源网
小青年技术网 » html插入数据例子