0

我刚刚将我们的 jquery 库从 v1.3.2 更新到 1.7.2,这是唯一需要修复的脚本 (endless_page.js)。我假设这里的语法已被贬值或其他什么,但任何帮助将不胜感激!!!

 var currentPage = 1;
 var path = window.location.pathname;
 var ajax_path;

function checkScroll() {
  if (nearBottomOfPage()) {
    call_ajax();
}  else {
   setTimeout("checkScroll()", 100);
 }
}

function call_ajax() {

    $("#loading-or-more").fadeOut(100, function() {
    $(this).replaceWith('<p class="headline" id="loading-or-more" style="display:none;text-align:center;margin-left:20px;"><img src="../../images/newlajaxoader.gif" style="float:left;margin-top:-10px;" > 10 more items on the way</p>');
    $("#loading-or-more").fadeIn(10);
    });
    currentPage ++;
    ajax_path = full_path(currentPage);
    $.ajax({
    url: ajax_path ,
    success: function(data) { 

        if (data=="false") { 
            $("#loading-or-more").replaceWith('<p class="headline" id="end-of-scroll" style="display:none;text-align:center;">  <a href="#"  class="submit gradientBGRed morecategories"> Back to top &uarr;  </a> </p>'); 
            $("#end-of-scroll").fadeIn(10);
            }
        else {
                $(".mb-lot-items").append(data); 
                // $(".ajax-results-list").slideDown('slow');
                checkScroll();                                                  
                $("#loading-or-more").replaceWith('<a  id="loading-or-more" class="headline gradientBGRed morecategories" href="#items-ajax-mobile"><span>More items</span></a>');  }

          } 
    });
}

function nearBottomOfPage() {
  return scrollDistanceFromBottom() < 400;
}

function scrollDistanceFromBottom(argument) {
  return $(document).height() - ($(window).height() + $(window).scrollTop());
}

function full_path(currentPage) {
    return (path+"?page=" + currentPage+"&format=js") ;
}

$(document).ready(function() { 
     // checks if "MORE" exists, if so calls checkscroll
     if ($("#loading-or-more").length) { checkScroll(); }
    });
4

1 回答 1

0

我必须将数据类型指定为文本,然后她开始获取数据。谢谢@Ohgodwhy

    dataType: "text",
于 2012-06-29T14:40:38.023 回答