在JQuery中指定的时间内未显示图像
在我的网页中,我使用自动滚动显示数据库中的数据。因此,每次向下滚动页面时,都会调用一个ajax函数,该函数将从数据库中获取下一组记录,并将其附加到网页中的最后一个内容在JQuery中指定的时间内未显示图像,jquery,html,ajax,settimeout,autoscroll,Jquery,Html,Ajax,Settimeout,Autoscroll,在我的网页中,我使用自动滚动显示数据库中的数据。因此,每次向下滚动页面时,都会调用一个ajax函数,该函数将从数据库中获取下一组记录,并将其附加到网页中的最后一个内容div 下面是我用于自动滚动的AJAX函数 $(document).ready(function() { $(window).scroll(function(){ // scroll event if(($(document).height()-$(window).height()-$(document).sc
div
下面是我用于自动滚动的AJAX函数
$(document).ready(function()
{
$(window).scroll(function(){ // scroll event
if(($(document).height()-$(window).height()-$(document).scrollTop()) < 300){
last_msg_function();
}
});
});
function last_msg_function() // function called on page scrolling
{
var ID=$('#maxid').val(); // Id of a hidden field for getting the starting offset for next fetching
var newID=parseInt(ID)+1;
$('#maxid').val(newID);
if(ID != 'NULL')
{
$.ajax({
type:'post',
datatype:'html',
data:'last_msg_id='+newID,
url:"<?php echo base_url();?>/index.php/member/scrollfunction",
success:function(response)
{
if(response!="") // if there is response then show image for some time
{
$('div#last_msg_loader').html('<img src=<?php echo base_url();?>images/page-loader.gif>');
$('div#last_msg_loader').show();
$('div#last_msg_loader').fadeIn().delay(5000).fadeOut();
//setTimeout(function() { $("div#last_msg_loader").hide();}, 2000 );
$(".subupdatediv:last").after(response); // append after the last div with class subupdatediv
}
else // if there is no response, then not show the loading image
{
$("div#last_msg_loader").hide();
}
}
});
}
}
及
但两者都不起作用。如果有响应,谁能帮我显示加载图像一段时间,然后将响应附加到页面上。加载图像div
如下所示:
<div id="last_msg_loader" style="height:230px; margin-left: 45%"></div>
提前感谢您的帮助。您可以做的一件事是显示淡出后的响应 那就好像
if(response!="")
{
$('div#last_msg_loader').html('<img src=<?php echo base_url();?>images/page-loader.gif>');
$('div#last_msg_loader').fadeIn(1000).fadeOut(5000,function(){
$(".subupdatediv:last").after(response);
});
}
else
{
$("div#last_msg_loader").hide();
}
if(响应!=“”)
{
$('div#last_msg_loader').html('images/page loader.gif>);
$('div#last_msg_loader').fadeIn(1000).fadeOut(5000,function(){
$(“.subupdatediv:last”)。在(响应)之后;
});
}
其他的
{
$(“div#last_msg_loader”).hide();
}
希望您已经隐藏了。最初是最后一个\u msg\u加载程序类
<div id="last_msg_loader" style="height:230px; margin-left: 45%"></div>
if(response!="")
{
$('div#last_msg_loader').html('<img src=<?php echo base_url();?>images/page-loader.gif>');
$('div#last_msg_loader').fadeIn(1000).fadeOut(5000,function(){
$(".subupdatediv:last").after(response);
});
}
else
{
$("div#last_msg_loader").hide();
}