scrolling signal working across browsers

I'm using the following to detect a scroll and retrieve a string to append to an existing one. It works inconsistently on some browsers. Can you help or point me to something that would solve this problem?
var page = 1;
$(window).scroll(function () {
if($(window).scrollTop() + $(window).height() == $(document).height()) {
page++;
var ht1 = document.getElementById('forum1').clientHeight;
var data1 = {'page_num':page, 'forum':'<?php echo $wu1 ?>', 'forum1':'<?php echo $position1 ?>', 'height':ht1};
$.ajax({
type: "POST",
url: "<?php bloginfo('template_url'); ?>/framework/theme-functions/data.php",
data:data1,
success: function(res) {
$("#forum1").append(res);
console.log(res);

Thanks