当用户滚动到页面底部时,它会导致我的数据库中的某些项目Lazy loading
。
以下是标题中的js:
<script type="text/javascript">
var counter = 0;
var categoryid = 93;
$(window).scroll(function(){
if ($(window).scrollTop() >= $(document).height() - $(window).height() - 10) {
$('div#loadmoreajaxloader').show();
counter = counter + 20;
$.ajax({
url: "loadmore.php?counter=" + counter + "&categoryid=" + categoryid,
success: function(html){
if(html){
$("#postswrapper").append(html);
$('div#loadmoreajaxloader').hide();
}else{
$('div#loadmoreajaxloader').html('<center>No more coupons to show.</center>');
}
}
});
}
});
</script>
问题是,当我到达页面底部时,它会尝试刷新自己。但是我只是得到一个白色的屏幕。我不明白发生了什么???
当我转到loadmore.php?counter=20&categoryid=93
页面时,它会正常加载并输出我想要的html。
好的,我只是在输出一些非常简单的html时才能使用懒惰的工作。看起来问题在于它试图输出的内容。这就是我想要输出的内容,它有一些javascript,它看起来像是通过ajax导致一些问题:
<?php
echo "<div class='category rounded_box'>
<div class='category-thumbnail'>
<a href='http://www.mydomain.com/site/kensie.com' title='View more Kensie Coupon Codes'>
<img src='http://static.mydomain.com/images/logo-small.jpg' width='88' height='31'
border='0' alt='Kensie - Logo' class='logo' /></a></div>
<div class='coupon_details_homepage'>
<div class='category_title'>
<div class='coupon_title_homepage'>
40% off when you share with your friends.
</div>
</div>
<div class='calltoaction'>
<a class='box' onclick='popup(http://www.mydomain.com/go/23147)' rel='nofollow' href='#coupon-23147'>
Click Here to Activate Coupon </a>
</div>
<div style='clear: both; margin-top: 5px;'>
More <a href='http://www.mydomain.com/site/kensie.com' title='View more Kensie Coupon Codes'>
Kensie Coupon Codes</a>
</div>
</div>
</div>
<script type='text/javascript'>showtext('By clicking this link you have activated the coupon. View the newly opened Kensie window to view this deal!','coupon-23147')</script>";
?>
我已将其缩小到导致问题的原因。在html的末尾,我需要输出一个与输出链接交互的javascript函数。有办法解决这个问题吗?
<script type='text/javascript'>showtext('By clicking this link you have activated the coupon. View the newly opened Kensie window to view this deal!','coupon-23147')</script>