function load_ad(site_name, tag, callback) { let data = { site_name: site_name, tag: tag, }; $.ajax({ type: 'POST', url: 'https://ad-man.newmatter.eu/api/ad', dataType: 'json', data: data, success: function (data) { if (data.success == false) return; callback(data.result); } }); } $(function() { $('[data-ad-man-type="template"]').each(function() { let tag = $(this).data('ad-man-tag'); let element = $(this); load_ad(ad_man_site_name, tag, function(ad_info) { if (ad_info == 'unknown_ad_slot') return; if (ad_info == 'no_ad') return; if (ad_info.raw_html.length > 0) { element.html(ad_info.raw_html).show(); return; } if (ad_info.iframe_src.length > 0) { let width = element.attr('data-ad-man-width'); let height = element.attr('data-ad-man-height'); element.find('[data-ad-man-type="a-href"]').attr('href', ad_info.url); element.find('[data-ad-man-type="image-src"]').replaceWith( '