【发布时间】:2017-09-02 16:43:55
【问题描述】:
我正在尝试使用 ajax php 和 jquery 无限滚动我的页面。 我已经粘贴了 jquery 代码 doe 参考。我正在尝试使用 jquery 和 php 按顺序发布。我的 jquery 代码将 counta 发送到 php 脚本。 php 脚本然后根据它收到的数字返回结果。我正在尝试按顺序发布帖子,以免它们重复。当用户到达页面底部时,我会收到帖子。
也欢迎任何其他答案。但我只想使用jquery的核心含义,不包含任何外部库。
var counta = 0;
$(document).ready(function(){
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() > $(document).height() - 2000) {
// console.log("Here");
$.ajax({
type: 'post',
url: 'extendost.php',
data: '&articles='+counta,
success: function (data) {
alert(counta);
$("#morepost").append(data);
counta++;
},
error: function (data) {
alert(data);
},
});
}
});
【问题讨论】:
标签: php jquery ajax infinite-scroll