How do I replace the "Argentina" key with a javascript variable string?
jQuery(document).ready(function() {
$.getJSON('countries.json', function(data) {
var output= data.Argentina[0].countryPhone1;
alert(output);
});
});
Here's what my .json data file looks like:
{
"Argentina": [{
"countryName":"Argentina",
"countryPhone1":"1234"
}],
"Brazil": [{
"countryName":"Brazil",
"countryPhone1":"5678"
}]
}
I tried applying the suggested solutions here, here and here, but I couldn't figure out a way to adapt them to my example.