-1
$(window).scroll(function() {
    if( $(window).scrollTop() == $(document).height() - $(window).height()) {
        $.ajax({
        type: "GET",
        url: "not_data.php",
        data: dataString,
        success: function my_func () {
           // display 10 new names.
        }
        });
    }
});

这是 not_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 请求并从表名中获取 10 个新名称。

$name 是 not_dat.php 中的唯一变量

4

1 回答 1

1

Try this:

$(window).scroll(function() {
  if( $(window).scrollTop() == $(document).height() - $(window).height()) {
    $.ajax({
    type: "GET",
    url: "not_data.php",
    data: dataString,
    success: function(data) {
       var htm = null;
       for(var i=0; i<data.length; i++) {
          htm += "<div>"+data[i]+"</div>";
       }
       $("container-div-id").append(htm);
    }
    });
  }
});
于 2013-09-25T12:24:08.010 回答