2 回答

TA貢獻1810條經驗 獲得超4個贊
創建一個用于加載圖像的元素。頁面加載時默認隱藏圖像。單擊按鈕時顯示 gif 圖像,然后在 success() 和 error() 中再次隱藏它。
<script>
$(document).ready(function(){
$("#formT button").click(function (ev) {
ev.preventDefault()
$("#loadingImage").show(); // <---
if ($(this).attr("value") == "btn_tool") {
$.ajax({
type: 'post',
url: '<?php echo APP_NAME;?>functions/app_form.php',
data: $('form').serialize(),
success:function(data){
$("#loadingImage").hide(); // <---
$("#statusT").html(data);
},
error:function (){
$("#loadingImage").hide(); // <---
}
});
}
});
});
</script>

TA貢獻1860條經驗 獲得超8個贊
您可以使用 JQuery 的 .hide() 函數隱藏 gif。
$('#loading-image').show();
$.ajax({
? ? ? url: uri,
? ? ? cache: false,
? ? ? success: function(html){
? ? ? ? $('.info').append(html);
? ? ? },
? ? ? complete: function(){
? ? ? ? $('#loading-image').hide();
? ? ? }
? ? });
- 2 回答
- 0 關注
- 195 瀏覽
添加回答
舉報