I want to know if the key-value pair exists in JSON data while retrieving data. Display "NA" inside div element if not present or else display the value of that key.
HTML:
<div id="output"></div>
jQuery:
$.get('http://api.fixer.io/2000-02-03',function(person){
if(person.hasOwnProperty('rates.BGN')) {
$('#output').text(person.rates.BGN);
}
else {
$('#output').text('NA');
}
});