Answer the question
In order to leave comments, you need to log in
Is it possible to track the connection callback of an external script and change the DOM it generates?
Please tell me:
I'm connecting a widget to the site from another resource.
script src="http://another-site.com/widjet.js" event-id="12345"
<div id="some-widjet">Какой-то текст</div>
...
$("#some-widjet").html("Новый текст");
...
Answer the question
In order to leave comments, you need to log in
Use $.getScript
https://api.jquery.com/jquery.getscript/
$.getScript('http://another-site.com/widjet.js', function() {
$("#some-widjet").html("Новый текст");
});
var el = document.createElement('script');
el.src = 'http://another-site.com/widjet.js';
el.onload = function() {
// Ваша логика, например
$("#some-widjet").html("Новый текст");
}
document.body.appendChild(el);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question