Files
mjs/900.обновление.js

41 lines
931 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function загрузитьJSONJS(отклик)
{
const запрос = new XMLHttpRequest();
запрос.onreadystatechange = function()
{
if (this.readyState == 4)
{
if (this.status == 200)
{
отклик(this.responseText);
}
else
{
console.error(this.status);
}
}
}
запрос.open("GET", "/json.js");
запрос.send();
}
function исполнитьJSONJS(текст)
{
if (!текст.length)
{
return;
}
const скрипт = document.createElement("script");
скрипт.src = текст;
document.body.appendChild(скрипт);
console.debug("исполнили скрипт", текст);
}
function обновитьJSONJS()
{
загрузитьJSONJS(исполнитьJSONJS);
}
setInterval(обновитьJSONJS, 1000);