I have a problem getting content and replacing the text using Reddit's subreddit Shower thoughts for data. What I'm trying to do is replace the h1 text with ID title to one from the JSON file but instead i get:
Uncaught SyntaxError: Unexpected number at the var thought.
This is my javascript file for changing the text
<script>
$.ajax({
url: 'https://www.reddit.com/r/showerthoughts/top.json',
dataType: 'json',
success: function( data )
{
var thought = data.children.0.data.title ;
var author = data.children.'0'.data.author ;
$('#title').text( thought );
}
});
</script>
This is the HTML file that has the title.
<body>
<h1 class="title" id="title">Hello ! It's me</h1>
<h5 class="author">- author</h5>
<video autoplay loop poster="forest.jpeg" id="bgvid" controls muted>
<source src="walk.mp4" type="video/mp4">
</video>
</body>