Здравствуйте. Нужна помощь. Необходимо сделать, что данный код выполнялся каждые 5 секунд с помощью setInterval:
Код:
|
if(typeof(xhr)=='undefined')
{
var xhr = new XMLHttpRequest();
}
xxxhr.open('GET', 'http://site.ru/api/index.php?data=x&subdata=y', true);
xxxhr.onload = function() {
document.getElementById("Screen3_mobilelabel_12").innerHTML = this.responseText;
}
xxxhr.onerror = function() {
document.getElementById("Screen3_mobilelabel_12").innerHTML = "Ошибка данных";
}
xxxhr.send(''); |
Как это можно грамотно реализовать?