Answer the question
In order to leave comments, you need to log in
How to reload a script without refreshing the entire page?
The script of the callback ordering service (envybox.io) is connected on the page. The page has the ability to select your region, each region has its own id, which is recorded in cookies. The callback service, depending on the ID in the cookie, substitutes the number of a specific manager answering the call. (Native geotargeting in the service does not work well, so I tied it to site cookies). But the problem is that after selecting the city (and overwriting the value in the cookie), you need to completely refresh the page location.reload();
so that the callback widget picks up the changed value. How can you reload a widget without refreshing the entire page?
Answer the question
In order to leave comments, you need to log in
you can create and place a script tag in the DOM
function reloadScript(url) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
document.documentElement.appendChild(script);
}
reloadScript('url to reload');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question