Reputation: 131
I use the following code to scroll to the bottom of a page.
function scrollToBottom() {
window.scrollTo(0,document.body.scrollHeight);
setTimeout(scrollToBottom, 1000);
}
I need to alert myself when I am done loading all the content, the content is loaded with ajax when I load to the bottom of the page, just like popular social media sites like twitter, facebook, youtube and tumblr do, in this case I am trying to do it with tumblr.
Upvotes: 0
Views: 50
Reputation: 1074
To set the alert when your ajax call is done loading, you need to place your code in the ajax callback handler. If you're doing this with pure javascript then
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
alert('content loaded!');
}
};
xhttp.open("GET", "ajax_info.txt", true);
xhttp.send();
If you're doing it with jQuery, then
$.ajax({
url: "ajax_info.txt",
success: function(result){
alert('content loaded!');
}
});
Upvotes: 1