Last active
April 19, 2016 13:52
-
-
Save rionmonster/4e347aacacf9ba636849e16653579d55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
} | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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