I have three json files (classical.json, rock.json and ragtime.json) at a website, and an html button which allows user to select one. I want to use js fetch to populate data with the json.
But it doesn’t work! I’m new to js fetch because previously I relied on php includes. Why doesn’t this work? Why do I get An error occurred
https://communitychessclub.com/music.php?jb=ragtime
{"YT_id":'mrLFPYENwOQ', "title":"Gladiolus Rag (Scott Joplin)", "author":'Cory Hall'},
{"YT_id":'hzRWvPMzyCU', "title":"Solace (Scott Joplin)", "author":'Cory Hall'},
{"YT_id":'BweSQtoc8D0', "title":"Magnetic Rag (Scott Joplin)", "author":'Cory Hall'}
function displayData(data) { console.log(data);}
function see_more (newegg) {grab_it = newegg + '.json'; //alert (grab_it);
fetch(grab_it)
.then(function(response) { return response.json(); })
.then(function(data) { displayData(data); })
.catch(function(error) { console.log('An error occurred:', error); });}