jQuery.fn.extend({ linklist: function (kwargs) { var self = $(this); $.ajax({ url: dataurl, async:true, contentType:"application/json", dataType: "json", success: function(data){ $.each(data, function(key, attributes2){ var sitename = attributes2.sitename $.each(attributes2.sites, function(key, attributes){ var my_link = (typeof attributes['link'] != 'undefined') ? attributes['link'] : ""; var my_button = (typeof attributes['button'] != 'undefined') ? attributes['button'] : ""; var my_name = (typeof attributes['name'] != 'undefined') ? attributes['name'] : ""; var my_image = ((typeof attributes['image'] != 'undefined') && (attributes['image'] == "empty")) ? my_name : attributes['image']; var new_div = $("