gpt4 book ai didi

javascript - 滚动时新的 ajax 请求

转载 作者:行者123 更新时间:2023-11-28 01:56:50 25 4
gpt4 key购买 nike

这是 JavaScript

 $(window).scroll(function() {
$.ajax({
type: "GET",
url: "not_data.php",
data: dataString,
success: function my_func () {
//show new name
}
});
});

这不是_data.php

<?php

$name_query=mysql_query("SELECT name FROM names");
while($run_query = mysql_fetch_assoc($name_query)) {
$name = $run_query['name'];

echo $name;
}
?>

我想调用一个新的ajax请求,并在每次用户向下滚动时从表名中获取一个新名称

最佳答案

看看这个优秀的 jquery 插件!

http://jscroll.com/

jScroll is a jQuery plugin for infinite scrolling, written by Philip Klauzinski. Infinite scrolling; also known as lazy loading, endless scrolling, autopager, endless pages, etc.; is the ability to load content via AJAX within the current page or content area as you scroll down. The new content can be loaded automatically each time you scroll to the end of the existing content, or it can be triggered to load by clicking a navigation link at the end of the existing content.

关于javascript - 滚动时新的 ajax 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18982935/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com