0

Is anyone able to tell me why the Image isn't getting appended to the div? I just want to generate the image URL in the code with the image URL from the JSON file. I'm stuck.

// JSON
{
    "Country": "Austria",
    "Image": "img-url"
}

var json = (function() {
    var json = null;
    $.ajax({
        'async': false,
        'global': false,
        'url': 'url',
        'dataType': "json",
        'success': function(data) {
            json = data;
        }
    });
    return json;
})();

$(json).each(function() {
    if (this.Country === "Austria") {
        $('#austria').append('<div class="img"><img src="'+ this.Image +'"/></div>');
    }
});
<div id="austria"></div>
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339

0 Answers0