Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/407.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 当滚动到窗口顶部时,加载jQuery结果_Php_Javascript_Jquery_Ajax - Fatal编程技术网

Php 当滚动到窗口顶部时,加载jQuery结果

Php 当滚动到窗口顶部时,加载jQuery结果,php,javascript,jquery,ajax,Php,Javascript,Jquery,Ajax,我有一个功能,当我点击一个按钮时,我从我的表格中调用更多的结果,当按钮在窗口顶部100像素时,我试图让它工作,但是我似乎无法让它工作 $(function(){ $('#showMore').click(function(event) { event.preventDefault(); var number = $(".directory").children().length; $.ajax({ type: "POST", url:

我有一个功能,当我点击一个按钮时,我从我的表格中调用更多的结果,当按钮在窗口顶部100像素时,我试图让它工作,但是我似乎无法让它工作

 $(function(){
  $('#showMore').click(function(event) {
     event.preventDefault();
     var number = $(".directory").children().length;
    $.ajax({
       type: "POST",
       url: "getentries.php",
       data: "count="+number,
       success: function(results){
         $('.directory').append(results);
       }
     });

  });
}))

到目前为止我已经试过了

 $(function(){
  $('#showMore').offset(function(event) {
    ....
jQuery
.offset()
函数不用于建立事件处理程序。您正在查找
.scroll()
。在“滚动”事件的事件处理程序中,可以使用
.offset()
查找当前位置

我将提出警告,浏览器会触发大量的滚动事件,因此在用户滚动窗口之前,您可能需要引入延迟