Skip to content

Instantly share code, notes, and snippets.

@xmlking
Created August 22, 2011 21:20
Show Gist options
  • Save xmlking/1163625 to your computer and use it in GitHub Desktop.
Save xmlking/1163625 to your computer and use it in GitHub Desktop.
jQuery's AJAX polling
$.ajax({
url : "chatlog",
success : function(message) {
if (message && message.length) {
var messagesDiv = $('#messages');
messagesDiv.html(message);
messagesDiv.animate({ scrollTop: messagesDiv.attr("scrollHeight") - messagesDiv.height() }, 150);
}
timer = poll();
},
error : function() {
timer = poll();
},
cache : false
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment