Skip to content

Instantly share code, notes, and snippets.

@rionmonster
Last active April 19, 2016 13:52
Show Gist options
  • Save rionmonster/4e347aacacf9ba636849e16653579d55 to your computer and use it in GitHub Desktop.
Save rionmonster/4e347aacacf9ba636849e16653579d55 to your computer and use it in GitHub Desktop.
// Keep track of how many users you have pulled
var usersPulled = 0;
// Every 5 seconds, pull a user
var userTimer = setTimeout(function(){ pullUser(); }, 5000);
function pullUser(){
// Make an AJAX call to pull your specific user
$.get('/Users/Get', { skip: usersPulled++ }, function(user){
if(user)
{
// Get the user that was pulled and output them
$('#userlist').append('<p>' + user + '</p>');
}
else
{
// No user was found, stop your timer
clearTimeout(userTimer);
}
});
}
public string Get(int skip)
{
// Get the first user available
var user = _context.Users.OrderBy(u => u.Name).Skip(skip).FirstOrDefault();
if(user != null)
{
return user.Name;
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment