I intend to load extra content on scroll to bottom in a div, but have been so far unable to make the jquery detect scroll to bottom. I know there are many questions here asking the same.. but none of the solutions have worked for me. I clearly have been doing something wrong, but being new at this can't figure out what. here is the code:
<html>
<head>
<script src="jquery-1.10.1.min.js">
</script>
<script>
$(document).ready(function(){
var n1=0;
var n2=5;
var $win = $(window);
$("#page").change(function(){
var str=$(this).val()
console.log(str);
if(str.length===0){$("#rssoutput").html("");}
else
{$("#rssOutput").load("http://dodomain.uni.me/getrss.php?q="+str+"&n1="+n1+"&n2="+n2);}
});
$(window).scroll(function() {
if (document.documentElement.clientHeight + $(document).scrollTop() >= document.body.offsetHeight )
{
alert("bottom of the page.");
}
});
});
</script>
</head>
<body>
<form>
<select id="page">
<option value="">Select an RSS-feed:</option>
<option value="Google">Google News</option>
<option value="cyanide">cyanide and happiness</option>
<option value="oglaf">Oglaf</option>
<option value="xkcd">xkcd</option>
<option value="wired">wired.com</option>
</select>
</form>
<br>
<div id="rssOutput" >RSS-feed will be listed here...</div>
</body>
</html>
I probably provided more code than needed.. but I'm unsure if the problem is elsewhere. The php just sends generates some html off rss feeds . Its online here http://dodomain.uni.me/rss.html
Edit: the code works when the contents of the div is static (ie not loaded via ajax) as demonstrated here http://jsfiddle.net/jkh5P/