I ain't very experienced with coding, so i am just asking for someone to put a code together for me, probably not advanced at all, i am using this code for a website i am building in HTML:
$.getJSON('https://www.googleapis.com/youtube/v3/videos?part=statistics&id=Qq7mpb-hCBY&key=[KEY]', function(data) {
document.write("viewCount: " + data.items[0].statistics.viewCount);
});
That is the code i currently use, but the "document.write" doesn't work, as it deletes the rest of the HTML page. What can i use instead of "document.write"? I know there is all the innerHTML, but i don't understand it enough, and i can't get it to work with the way the rest of the code is made. Maybe someone could figure out a script for me so i can actually get this youtube view count on my HTML page as text. Thank you If you guys don't understand what i am doing, then ask, i am simply trying to put the data of the youtube video onto my HTML page
The jQuery append
function will append the content to the body.
$.getJSON('https://www.googleapis.com/youtube/v3/videos?part=statistics&id=Qq7mpb-hCBY&key=AIzaSyDwBd3B-BdNIglXT44obKjINRe5c6tRFvQ', function(data) {
$('body').append("viewCount: " + data.items[0].statistics.viewCount);
});