Проверить Matter.js
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
931B

  1. function загрузитьJSONJS(отклик)
  2. {
  3. const запрос = new XMLHttpRequest();
  4. запрос.onreadystatechange = function()
  5. {
  6. if (this.readyState == 4)
  7. {
  8. if (this.status == 200)
  9. {
  10. отклик(this.responseText);
  11. }
  12. else
  13. {
  14. console.error(this.status);
  15. }
  16. }
  17. }
  18. запрос.open("GET", "/json.js");
  19. запрос.send();
  20. }
  21. function исполнитьJSONJS(текст)
  22. {
  23. if (!текст.length)
  24. {
  25. return;
  26. }
  27. const скрипт = document.createElement("script");
  28. скрипт.src = текст;
  29. document.body.appendChild(скрипт);
  30. console.debug("исполнили скрипт", текст);
  31. }
  32. function обновитьJSONJS()
  33. {
  34. загрузитьJSONJS(исполнитьJSONJS);
  35. }
  36. setInterval(обновитьJSONJS, 1000);