How do I access the data from this Json file. For example return the name:
{
"potions": {
"1": {
"id": 1,
"name": "Aging Potion",
"image": "aging-potion.png",
"price": 29.99,
"effect": "Causes the drinker to advance in age",
"ingredients": [
"Red Wine",
"Prune Juice",
"Hairy Fungus",
"Tortoise Shell",
"Caterpillar",
"Bat Tongue"
]
},
}
}
My Ajax looks like this:
var get = function(url, callback){
var teste = new XMLHttpRequest();
teste.onreadystatechange = function(){
if(teste.readyState == 4){
callback(teste.responseText, teste.status);
}
};
teste.open('Get', 'potions.json', true);
teste.send(get);
};
get('potions.json', function(data){
document.getElementById('pteste').innerHTML = data.potions['1'].name;
});