if(!window.jQuery) { var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'; document.getElementsByTagName('head')[0].appendChild(script); script.addEventListener('load', function(){ jQuery(function(){ swbExternalBlockInit(); }); }, false); } else { jQuery(function(){ swbExternalBlockInit(); }); } function swbExternalBlockInit() { jQuery('[data-swb-id]').each(function(){ var params = $(this.attributes).map(function(){ if (/^data\-swb\-/.test(this.name)) return this.name+'='+encodeURIComponent(this.value); }).get().join("&"); var element = jQuery(this); jQuery.getJSON('http://togor.ru/api/startwithbitrix/external_block_out.php?'+params+'&callback=?', function(data){ element.html(data.html); }); }); }