将此添加到你的index.html或js文件中(我假设你在这里有jQuery,你当然可以使用标准javascript。):
<script type="text/javascript">// <![CDATA[ function loading(){ $("#loading").show(); $("#content").hide(); }// ]]></script>将此添加到你的html或css文件中:
div#loading { width: 35px; height: 35px; display: none; background: url(/static/loadingimage.gif) no-repeat; cursor: wait; }然后更改你的提交按钮以调用上面的js函数:
<input type="submit" name="anything_submit" value="Submit" onclick="loading();">
并在你的基本html文件中添加加载内容和内容div:
<body> <div id="loading"></div> <div id="content"> <h3>Type anything:</h3> <p> <form action="." method="POST"> <input type="text" name="anything" placeholder="Type anything here"> <input type="submit" name="anything_submit" value="Submit" onclick="loading();"> </form> </p> </div> </body>
现在,当你单击“提交”时,js函数应隐藏你的内容并显示加载的GIF。这将一直显示,直到处理完你的数据并且flask加载新页面为止。



