Its my first time posting here but i'm desperate for a solution. I'm sorry in advance if my question format is not proper. So basically what i'm struggling with is appending json data to paragraphs in my html. My API is okay, i checked with console.log the data is there, but every time i try to append the data, an error pops up in my console stating: Uncaught TypeError: Cannot read property 'Drivers' of undefined.
I've tried removing MRData from function but that didn't seem to do anything.
$.getJSON("http://ergast.com/api/f1/2016/drivers.json", function(MRData) {
console.log(MRData);
var drId = MRData.DriverTable.Drivers[0].driverId;
var permanentNum = MRData.DriverTable.Drivers[0].permanentNumber;
var kod = MRData.DriverTable.Drivers[0].code;
$('#p0').append(drId);
$('#p1').append(permanentNum);
$('#p2').append(kod);
})
<body>
<p id="p0"></p>
<p id="p1"></p>
<p id="p2"></p>
</body>
What I'm hoping to accomplish here is to get the strings from each of the variables and to append them to my paragraphs.