Javascript 在使用get()加载页面之前加载图像
如何在加载过程中显示gif图像 我使用getJavascript 在使用get()加载页面之前加载图像,javascript,jquery,ajax,load,loading,Javascript,Jquery,Ajax,Load,Loading,如何在加载过程中显示gif图像 我使用get function getCurrentUrl() { $( $.get( "page1.html", function (data) { $("#divReceptLoad").empty().append(data); }, 'html' ) ); } 如果您能帮助我,我会
function getCurrentUrl() {
$(
$.get(
"page1.html",
function (data) {
$("#divReceptLoad").empty().append(data);
},
'html'
)
);
}
如果您能帮助我,我会非常感谢您:)创建一个
,然后:
function getCurrentUrl() {
$('#loading').show(); //show it before sending the ajax request
$.get("page1.html", function (data) {
$('#loading').hide(); //hide in the callback
$("#divReceptLoad").empty().append(data);
},'html'));
}
您可以随意为图像添加更多样式/定位,并将基本的show
/hide
方法替换为/,/或者如果您愿意的话
这里有一个例子,以防你不想从谷歌图片中抓到一个
这是一些预制的。像这样吗?
function getCurrentUrl() {
$('#gif').fadeIn() // show the hidden gif
$.get("page1.html", function(data){
$('#gif').hide() // hide it
$("#divReceptLoad").empty().append(data);
},'html')
}