【发布时间】:2015-01-27 10:51:04
【问题描述】:
我有一个这样的容器:
<div class="row row-sm padder-lg ">
<div class="col-xs-6 col-sm-4 col-md-3 col-lg-2">
...
</div></div>
内容是通过这个循环在一个php页面上生成的:
<?php
foreach ($top->feed->entry as $key => $value)
{
$value->title->label = str_ireplace( "- ".$value->artist->label, "", $value->title->label);
if($key >= $this->config->item("items_top"))
return false;
$image = $value->image[2]->label;
if($image == '')
$image = base_url()."assets/images/no-cover.png";
$image = str_ireplace("170x170", "200x200", $image);
?>
“items_top”是最大数组的数量。要显示的图像,如何在滚动时增加负载? 所以当用户在页面底部滚动时会自动加载新内容
更新
好的,我需要使用 Ajax,但该怎么做?在我的 php 中使用此代码是否正确?
<script>
$(document).scroll(function(e){
// grab the scroll amount and the window height
var scrollAmount = $(window).scrollTop();
var documentHeight = $(document).height();
// calculate the percentage the user has scrolled down the page
var scrollPercent = (scrollAmount / documentHeight) * 100;
if(scrollPercent > 50) {
// run a function called doSomething
doSomething();
}
function doSomething() {
// do something when a user gets 50% of the way down my page
}
});
</script>
【问题讨论】:
-
您似乎想在这个过程中使用一些 AJAX 函数。这些功能你知道吗?
-
@Zeratops 是的,我需要 Ajax,但我从未使用过它。您能帮我解决我在问题底部发布的脚本吗?谢谢
标签: javascript php jquery apache codeigniter