我需要实时显示我的内容,但是当加载这么多东西时,它会占用大量 CPU 并且非常滞后。
下面的代码有替代方法吗?
$(document).ready(function() {
var refresh_bal = setInterval(
function (){
$.get('./php/get_balance.php', function(balance) {
$('.balance').html(balance);
});
}, 1000);
var refresh_total = setInterval(
function (){
$.get('./php/get_total_bets.php', function(total) {
$('.total').html(total);
});
}, 1000);
var refresh_profit = setInterval(
function (){
$.get('./php/get_profit.php', function(profit) {
$('.profit').html(profit);
});
}, 1000);
$('.haa').on('click', function() {
var refresh_bets = setInterval(
function (){
$.get('./php/get_bets.php', function(bets) {
$('.betsTable').html(bets);
});
}, 1000);
});
var refresh_site = setInterval(function (){
$.get('./php/get_site.php', function(site) {
$('.siteStats').html(site);
});
}, 1000);
var refresh_client = setInterval(function (){
$.get('./php/get_client.php', function(client) {
$('.clientShow').html(client);
});
}, 1000);
var refresh_server = setInterval(function (){
$.get('./php/get_server.php', function(server) {
$('.serverShow').html(server);
});
}, 1000);
$('.ha').on('click', function() {
var refresh_chat = setInterval(function() {
$.get('./php/get_chat.php', function(chats) {
$('.chats').html(chats);
});
});
});
});