i started to learn json and ajax and i have this json file:
{
"data": {
"children": [{
"data": {
"domain": "some.url.com"
},
{
"data": {
"domain": "another.url.com"
}
}
}]
}
}
How i get the first domain from this file?
I try:
$(document).ready(function(){
$.getJSON("https://myurl.com/api.json", function(data){
console.log(data.children[0].data.domain);
});
});
and it didn't work :(
Look closely on your data and your code.
You've got data variable, then data object with children array so you can access it like that
data.data.children[0].data.domain
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With