Created
August 1, 2018 18:32
-
-
Save dongcai/158d9b7ce68cf89def67b4c2a499b707 to your computer and use it in GitHub Desktop.
Every request only updates what it needs to be updated
This file contains hidden or 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
| function getRedditFeed() { | |
| var topic = $('#select-topic').val(); | |
| $.getJSON("https://www.reddit.com/r/" + topic + ".json", function(data) { | |
| $.each(data.data.children, function(i, item) { | |
| $('<li><a href="' + item.data.url + '" target="_blank">' + item.data.title + '</a></li>').appendTo("#posts"); | |
| }); | |
| }); | |
| } | |
| $(document).ready(function() { | |
| getRedditFeed(); | |
| $('#select-topic').change(function() { | |
| $('#posts').html(''); // clear posts | |
| getRedditFeed(); | |
| }) | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment