0
嗨,我們已經在我們的網站內實現了無限滾動功能。所有在Chrome中運行良好,但Firefox和I.e不加載下面的JavaScript代碼?我們確實有https,那麼這可能是問題,如果是的話,我們如何解決它。 貝婁是我們當前的代碼Jquery問題在Firefox和IE但不是Chrome
$(document).ready(function() {
var ajax_arry = [];
var ajax_index = 0;
var sctp = 100;
$('#loading').show();
$.ajax({
url:"ajax.php",
type:"POST",
data:"function=showData&type=homeactivity&page=1",
cache: false,
success: function (response) {
$('#loading').hide();
$('#postStatus1').html(response);
}
});
$(window).scroll(function() {
var height = $('#postStatus1').height();
var scroll_top = $(this).scrollTop();
if(ajax_arry.length>0) {
$('#loading').hide();
for(var i=0; i<ajax_arry.length; i++) {
ajax_arry[i].abort();
}
}
var page = $('#postStatus1').find('.nextpage').val();
var isload = $('#postStatus1').find('.isload').val();
if($(window).scrollTop() == $(document).height() - $(window).height() && isload=='true') {
$('#loading').show();
var ajaxreq = $.ajax({
url: "ajax.php",
type: "POST",
data: "function=showData&type=homeactivity&page="+page,
cache: false,
success: function (response) {
$('#postStatus1').find('.nextpage').remove();
$('#postStatus1').find('.isload').remove();
$('#loading').hide();
$('#postStatus1').append(response);
}
});
ajax_arry[ajax_index++] = ajaxreq;
}
return false;
if($(window).scrollTop() == $(window).height()) {
alert("bottom!");
}
});
});
非常感謝您!
這個改變如何改進代碼? – AaronS
嗯..那是否解決了你的「加載」問題?我肯定有人可以解釋這比我更好,但簡單地說..不同的瀏覽器加載DOM不同... document.ready和window.load是不一樣的... document.ready做它做什麼時, DOM已準備好加載... window.load在加載頁面後執行此操作... –