页面加载More.Load()后Javascript代码停止工作

页面加载More.Load()后Javascript代码停止工作,javascript,Javascript,当在auto Load More上获取数据时,另一个JavaScript(如下所示)停止工作。 即使当它显示第一页默认值时,它也会在那里工作,但向下滚动后,它就不工作了 更新了索引和getdata文件的更多说明。我正在获取下面代码中提到的数据 index.php <div> <?php include('getdata.php'); ?> </div> <script> $(document).ready(function(){ var is_a

当在auto Load More上获取数据时,另一个JavaScript(如下所示)停止工作。 即使当它显示第一页默认值时,它也会在那里工作,但向下滚动后,它就不工作了

更新了索引和getdata文件的更多说明。我正在获取下面代码中提到的数据

index.php

<div>
<?php include('getdata.php'); ?>
</div>

<script>
$(document).ready(function(){
var is_ajaxed = false;
function getresult(url) {
    $.ajax({
    url: url,
    type: "GET",
    data:  {rowcount:$("#rowcount").val()+1},
    beforeSend: function(){
    $('#loader-icon').show();
    },
    complete: function(){
    $('#loader-icon').hide();
    },
    success: function(data){
    $("#faq-result").append(data);
    },
    error: function(){} 
    });
}
$(window).scroll(function(){
    if ($(window).scrollTop() >= ($(document).height() - $(window).height()-900) && is_ajaxed == false){
    if($(".pagenum").val() <= $(".total-page").val()) {
    var pagenum = parseInt($(".pagenum").val()) + 1;
    var pname = "<?php echo $pgianame; ?>";
    var sname = "<?php echo $stianame; ?>";
    getresult('sellers_forum_page_posts_getresult.php?page='+pagenum+'&pname='+pname+'&sname='+sname);
    is_ajaxed = true
    }
    }
    }); 
});
</script>

<?php
include ('db.php');

$perPage = 10;

$sql = "select * from posts where status = 1";
$faq3x = $dba3->query($sql);
$allrowscount = mysqli_num_rows($faq3x);
$pages  = ceil($allrowscount/$perPage);

$page = 1;
if(!empty($_GET["page"])) {
$page = $_GET["page"];
}

$start = ($page-1)*$perPage;
if($start <= 0) $start = 0;


$sqlsC = "select * from posts where status = 1 ";
$query =  $sql . " limit " . $start . "," . $perPage; 
$faq3xsC = $dba3->query($query);

echo '<input type="text" class="pagenum" value="'.$page.'" />';
echo '<input type="text" class="total-page" value="'.$pages.'" />';

while ($faqC = $faq3xsC->fetch_assoc()) {

$id =   $faqC['id'];

$ext        =   ".doc";
$name       =   $id.$ext;
$filepath   =   "blog/posts/";

$filename   =   $filepath.$name;

if(file_exists($filename)) {
    if(($fhP = fopen($filename, 'r')) !== false ) {
       $headersxP = fread($fhP, 999000);
       $commentsPP  = nl2br($headersxP);
$countxP = 0;
$fhxP = fopen($filename, 'r');
while(!feof($fhxP)){
    $frxP = fread($fhxP, 999999);
    $countxP += strlen($frxP);
}
fclose($fhxP);
?>

<?php echo substr($commentsPP, 0, 511); ?>
<span id="dots_<?php echo $idPost; ?>">...</span>
<span id="more_<?php echo $idPost; ?>" style="">
<?php echo substr($commentsPP, 512, 999999); ?>
</span>
<a onclick="myFunctionx_<?php echo $id; ?>()"
id="myBtn_<?php echo $id; ?>"> See More <i class="fa fa-long-arrow-right"></i></a>

<script>
function myFunctionx_<?php echo $id; ?>() {
  var dots_<?php echo $id; ?> = document.getElementById("dots_<?php echo $id; ?>");
  var moreText_<?php echo $id; ?> = document.getElementById("more_<?php echo $id; ?>");
  var btnText_<?php echo $id; ?> = document.getElementById("myBtn_<?php echo $id; ?>");

  if (dots_<?php echo $id; ?>.style.display === "none") {
    dots_<?php echo $id; ?>.style.display = "inline";
    btnText_<?php echo $id; ?>.innerHTML = "&nbsp;See more <i class='fa fa-long-arrow-right'></i>"; 
    moreText_<?php echo $id; ?>.style.display = "none";
  } else {
    dots_<?php echo $id; ?>.style.display = "none";
    btnText_<?php echo $id; ?>.innerHTML = "&nbsp;<i class='fa fa-long-arrow-left'></i> See less"; 
    moreText_<?php echo $id; ?>.style.display = "inline";
  }
}
</script>
<?php } ?>

$(文档).ready(函数(){
var为_ajaxed=假;
函数getresult(url){
$.ajax({
url:url,
键入:“获取”,
数据:{rowcount:$(“#rowcount”).val()+1},
beforeSend:function(){
$(“#加载程序图标”).show();
},
完成:函数(){
$(“#加载程序图标”).hide();
},
成功:功能(数据){
$(“#常见问题解答结果”)。追加(数据);
},
错误:函数(){}
});
}
$(窗口)。滚动(函数(){
if($(窗口).scrollTop()>=($(文档).height()-$(窗口).height()-900)和&is_ajaxed==false){

如果($(“.pagenum”).val()您从未调用过
myFunctionx
,那么很难看出这是如何工作的。@Quentin请检查,现在我已经更新了我的问题,仍然不是一个线索。您需要一个@Quentin,请检查,现在我已经更新了。或者您想要一个加载更多等的完整示例。@freedomn-m您能找到解决方案吗?