[英]Why doesn't this infinite scroll work in IE?
The code below works as intended for Chrome and Firefox. 以下代码适用于Chrome和Firefox。 For IE, it scrolls through the same content. 对于IE,它会滚动浏览相同的内容。 I searched extensively for a solution but found nothing. 我进行了广泛的搜索以寻找解决方案,但没有发现任何问题。
Header 标头
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(window).scroll(function()
{
if($(window).scrollTop() == $(document).height() - $(window).height())
{
$('div#loadmoreajaxloader').show();
$.ajax(
{
url: "http://www.hackedflashgames.com/loadmore.php",
success: function(html)
{
if(html)
{
$("#wrapper").append(html);
$('div#loadmoreajaxloader').hide();
}else
{
$('div#loadmoreajaxloader').html('<center>No more posts to show.</center>');
}
}
});
}
});
</script>
loadmore.php loadmore.php
<?php
include('db.php');
$stmt = $db->prepare("SELECT * FROM games ORDER BY RAND() LIMIT 6");
if($stmt->execute()){
while ($row = $stmt->fetch()) {
echo'
content here
';
}
}
?>
IE is renown for it's aggressive caching especially with AJAX. IE以其积极的缓存而闻名,尤其是AJAX。
Try adding some random query string to the URL for the ajax call (like a timestamp). 尝试将一些随机查询字符串添加到ajax调用的URL中(例如时间戳记)。
You could also specify this in your code : $.ajaxSetup({ cache: false });
您也可以在代码中指定: $.ajaxSetup({ cache: false });
Thus you won't have to manually add the query string, jQuery will take care of it. 因此,您不必手动添加查询字符串,jQuery会照顾好它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.