我刚刚将我们的jquery库从v1.3.2更新到1.7.2,这是唯一的脚本(endless_page.js)还剩下要解决的问题。我假设这个中的synstax是折旧的或者其他东西,但任何帮助都会非常感激!!!
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 ↑ </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(); }
});
答案 0 :(得分:0)
我必须将数据类型指定为文本,然后她开始获取数据。谢谢@Ohgodwhy
dataType: "text",