Last active
August 29, 2015 13:57
-
-
Save jrolfs/9494205 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
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