I'm new to web development, and I have a problem I can't solve.
Problem: I need to show content after loading that content.
## file.js ##
//on click this code run!
//and after click i see web site load content
var toInsert = $('<div class="togllecomposition tg'+number+'">\
<div class="infoclip">'+info+'</div>\
<iframe width="420" height="315" src="'+clip+'" frameborder="0" allowfullscreen></iframe>\
<div class="comments">\
<div class="commentlabel">Комментарии:</div>\
<div class="comment">\
<div id="hypercomments_widget'+id_composition+'"></div>\
' + _hcwp.push({widget:"Stream", widget_id: ID, xid: id_composition, append:"#hypercomments_widget"+id_composition, hc_disabled: 1}) +'\
</div>\
</div>\
</div>');
//this didn't work
$(toInsert).load(function() {
$(".composition".concat(number)).after(toInsert);
});
// this work but with lags because content in process of loading
$(".composition".concat(number)).after(toInsert);
How can I solve this problem?