Code:
$(document).ready(function() {
setInterval('USDBTC()',2000);
setInterval('RSDEUR()',2000);
setInterval('USDEUR()',2000);
setInterval('USDXAU()',2000);
});
function USDBTC() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById('usdbtc').innerHTML = this.responseText;
}
};
xhttp.open('GET', '<?php echo ROOT; ?>scripts/usdbtc.php', true);
xhttp.send();
}
function RSDEUR() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById('rsdeur').innerHTML = this.responseText;
}
};
xhttp.open('GET', '<?php echo ROOT; ?>scripts/rsdeur.php', true);
xhttp.send();
}
itd...
$(document).ready(function() {
setInterval('USDBTC()',2000);
setInterval('RSDEUR()',2000);
setInterval('USDEUR()',2000);
setInterval('USDXAU()',2000);
});
function USDBTC() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById('usdbtc').innerHTML = this.responseText;
}
};
xhttp.open('GET', '<?php echo ROOT; ?>scripts/usdbtc.php', true);
xhttp.send();
}
function RSDEUR() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById('rsdeur').innerHTML = this.responseText;
}
};
xhttp.open('GET', '<?php echo ROOT; ?>scripts/rsdeur.php', true);
xhttp.send();
}
itd...
Kako bi vi ove dve funkcije smestili u jednu?