ajax加載後臺數據就不說的那麼細了。
看下面代碼首先前臺上放置代碼
<div id="loadgif" style="width:66px;height:66px;position:absolute;top:50%;left:50%;">
<img alt="加載中..." src="../../Images/loading1.gif"/>
</div>
在js腳本文件中首先把這個圖片動畫隱藏
代碼如下
$(document).ready(function () { $("#loadgif").hide();});
然後異步ajax提交請求代碼如下
$(function () {
var find = new Find();
//alert(find.Template);
$.ajaxSetup({
cache: false,
async: true,
global: false,
type: "POST"
});
$("#queryBtn").click(function () { $("#loadgif").show(); find.Get() });
.....................
注意:
async: true,
當點擊queryBtn按鈕的時候就調用動畫顯示
$("#loadgif").show();
然後提交請求
等收到請求後就
$("#loadgif").hide();
效果如下: