Skip to content

Instantly share code, notes, and snippets.

@jrolfs
Last active August 29, 2015 13:57
Show Gist options
  • Save jrolfs/9494205 to your computer and use it in GitHub Desktop.
Save jrolfs/9494205 to your computer and use it in GitHub Desktop.
var $messages = $(".messages")
function myFetchFunction() {
$.getJSON("https://api.parse.com/1/classes/chats?order=-createdAt", function (data) {
// Clear any old output from DOM
$messages.empty();
// Iterate through response and append each result as a list item
$.each(data, function (index, result){
for (var i = 0; i < result.length; i++) {
$messages.append('<li>' + result[i].text + '</li>');
};
});
});
// Lets refresh in 3 seconds
setTimeout(myFetchFunction, 3000);
};
// Initial call
myFetchFunction();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment