$.get({ url: location.href, dataType: 'html', success: function(data) { var $doc = $(data); var $fragments = ($doc && $doc.find('.js-sso')) || $(); $fragments.each(function() { var $out = $(this); var fragmentId = $out.attr('id'); var $placeholder = $('#' + fragmentId); $placeholder.replaceWith($out); }); $(document).trigger('sso:ajax:done'); } });