I can't figure out why this script won't work in Firefox. And, even though my ajax_loadmore.php
outputs FALSE, it still makes the AJAX-call (in Chrome).
var request;
$(window).scroll(function () {
if ($(window).scrollTop() == $(document).height() - $(window).height() ) {
var ID = $('.stbody:last').attr('id').match(/stbody(\d+)/)[1];
$('#loader').show();
if(request) {
return
}
request = $.ajax({
type: 'GET',
url: "ajax_loadmore.php?lCom="+ID,
success: function(result) {
if(result!='FALSE') {
$('#loader').hide();
$('#moreComments').append(result);
$(".oembed").oembed(null, {
embedMethod: "fill",
maxWidth: 700,
maxHeight: 600
});
request = null;
} else {
$('#loader').hide();
$('#moreComments').html('<center><p>Slut på inlägg</p></center>');
request = null;
}
}
});
}
});
ajax_loadmore.php
code:
<?php
if($_GET['lCom']) {
include_once 'core/init.php';
protect_page();
include_once 'includes/db.php';
include_once 'includes/functions.php';
include_once 'includes/tolink.php';
include_once 'includes/time_stamp.php';
include_once 'session.php';
$lCom = $_GET['lCom'];
$Wall = new Wall_Updates();
$updatesarray=$Wall->Updates_more($uid,$lCom);
if(!empty($updatesarray)) {
foreach($updatesarray as $data) {
$msg_id=$data['msg_id'];
$orimessage=$data['message'];
$message=tolink(htmlspecialchars(nl2br($data['message'])));
$time=$data['created'];
$username=$data['username'];
$uid=$data['uid_fk'];
$face=get_profile_pic($uid,'small');
$face2=get_profile_pic($session_user_id,'mini');
$commentsarray=$Wall->Comments($msg_id);
?>
//HTMLSTUFF HERE..
<?php
}
} else { echo 'FALSE'; }
} else { die('du ska inte vara här..'); }
?>
I was also faced with the same problem, and I used the script from the following link:
http://www.9lessons.info/2009/07/load-data-while-scroll-with-jquery-php.html
It seems to work now. I use jQuery to add a sticky class to my menu when it reaches the top. And that menu had position: relative on it wich probably messed with the height of the window or something so that Firefox didn't execute the script because it didn't reach the bottom.
When I changed the position: relative on the menu container to position: absolute it just worked.
If someone can explain why this is in more detail I would be happy! (because it worked in Chrome and IE I'm guessing its a rendering issue in Firefox)
Thanks for your replies!