views.py
@main.route('/demo')
def demo():
return render_template('demo.html')
@main.route('/load')
def load_view():
return render_template("load.html")
demo.html (以下为文件全部内容,在load.html中载入)
<h1>这是/demo中的核心内容</h1>
<div id="container">
<p class="title">
这是网页头部上的标题
</p>
<ul>
<li>首页</li>
<li>笔记本电脑</li>
<li>Maria老师视频库</li>
</ul>
</div>
load.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="/static/js/jquery-1.11.3.js"></script>
<script>
$(function () {
$("#btnLoad").click(function () {
var params = "uname=maria&uage=30";
$("#showDemo").load('/demo', params, function () {
window.setTimeout(function () {
$("#showDemo").slideUp(5000);
}, 5000);
});
});
});
</script>
<link rel="stylesheet" href="/static/css/demo.css">
</head>
<body>
<button id="btnLoad">加载/demo到网页中</button>
<div id="showDemo"></div>
</body>
</html>
demo.css
#container .title{
color: #f00;
font-size: 24px;
font-weight: bold;
}
#container ul li{
float: left;
width: 150px;
height: 30px;
text-align: center;
line-height: 30px;
margin-right: 15px;
background: #e4393c;
}