[英]Why doesn't this infinite scroll work in IE?
以下代碼適用於Chrome和Firefox。 對於IE,它會滾動瀏覽相同的內容。 我進行了廣泛的搜索以尋找解決方案,但沒有發現任何問題。
標頭
<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
<?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以其積極的緩存而聞名,尤其是AJAX。
嘗試將一些隨機查詢字符串添加到ajax調用的URL中(例如時間戳記)。
您也可以在代碼中指定: $.ajaxSetup({ cache: false });
因此,您不必手動添加查詢字符串,jQuery會照顧好它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.