如何向用戶顯示加載圖片和/或消息? 如果可能,我想知道如何使它成爲灰色背景的全屏幕。有點像從一些畫廊查看大圖片(對不起,沒有示例鏈接)。如何顯示jQuery正在工作/等待/正在加載?
當前我添加一個CSS類,它具有圖像和其他格式,但由於某種原因它不工作。 搜索結果會插入到div中。
HTML
<div id="searchresults"></div>
CSS
div.loading {
background-image: url('../img/loading.gif');
background-position: center;
width: 80px;
height: 80px;
}
JS
$(document).ready(function(){
$('#searchform').submit(function(){
$('#searchresults').addClass('loading');
$.post('search.php', $('#'+this.id).serialize(),function(result){
$('#searchresults').html(result);
});
$('#searchresults').removeClass('loading');
return false;
});
});