0

私のサイトは現在、7 つの DIV の情報を入力するために 6 つの異なる PHP ページをロードする必要があります。

5 秒ごとに更新するものもあれば、1 秒ごとに更新するものもあります。

1 秒ごとに 1 つの PHP ページをロードし、詳細をすべての DIV に分割します。そうすれば、3 つまたは 4 つのリクエストではなく、1 秒あたり 1 つのリクエストのみが送信されます。

そう --> api/getdata.php はエコーします: "$5.93, $10.36, 27:31 1, 22, Joe". 次に、JQuery は各コンマを異なる DIV に分割する必要があります。このようなもの:

setInterval(function() {$('#balance, #pot, #timer, #round, #id, #username').load('api/getdata.php');}, 1000);

Google で調べましたが、探しているものが見つかりませんでした。

私の現在の方法(非常に悪い)は次のとおりです。

<script type="text/javascript">
        $(document).ready(function() {
            $.ajaxSetup({ cache: false }); // This part addresses an IE bug. without it, IE will only load the first number and will never refresh
            $('#GetBalance, #GetBalanceWithdraw').load('get/GetBalance.php');
            $('#Clock').load('get/Clock.php');
            $('#GetPot').load('get/GetPot.php');

            setTimeout(function() {$('#errmsg').fadeOut('slow');}, 5000);
            setInterval(function() {
            $('#GetPot').load('get/GetPot.php');
            $('#TotalBids').load('get/TotalBids.php');
            }, 2500); 
            setInterval(function() {$('#GetBalance, #GetBalanceWithdraw').load('get/Balance.php');}, 5000);
            setInterval(function() {$('#GetBalance').load('get/Balance.php');}, 5000);
            setInterval(function() {$('#Clock').load('get/Clock.php');}, 1000);
        });
    </script>
4

2 に答える 2