我的views.py是这样的:
def findinfo(request):
return render(request,'findinfo.html')
def findresult(request):
items = []
testline = {}
for i in range(10):
testline['name'] = "nxy"
testline['id'] = "123456"
items.append(testline.copy())
return render(request,'findinfo.html',{'items':items})
我的findinfo.html模板是这样的:
<!DOCTYPE html>
<html>
<head>
<title>查询页面</title>
</head>
<body>
<form align="center" action="/findresult/" method="get">
查询条件: <input type="text" id="name" name="name"> <br><br>
<button type="button" id='find'>查询</button>
</br></br>
</form>
<table class="gridtable" align="center" id="pstable" border="1">
<thead>
<tr>
<th>姓名</th>
<th>编号</th>
</tr>
</thead>
<tbody>
{%for item in items%}
<tr>
<td>{{item.name}}</td>
<td>{{item.id}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</body>
</html>
<script src="http://apps.bdimg.com/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#find").click(function(){
$.get("/findresult/",{'name':name},
function(ret){
$('#pstable').html(ret)
})
});
});
</script>
打开页面显示:
点击查询显示:
table里又嵌入了一层查询按钮,这个怎么解决啊