1

私はJavascriptで次のコードを持っていますが、うまくいかないことがあります:

var new_c = 0;
function updateCounter()
{
    var last_c = $("span#counter").text();
    last_c = last_c.replace(",", "");
    last_c = parseInt(last_c);
    if (last_c < new_c)
    {
        last_c++;
        $("span#counter").text(last_c);
    }
}

function refreshCounter()
{
    $("<div>").load("includes/ajax/meter/counter.php",
    {
    }, function() {
        new_c = $(this).text().substr($(this).text().indexOf(";")+1);
        new_c = new_c.trim();
        new_c = parseInt(new_c);
    });
}

window.setInterval("refreshCounter()", 1000);
window.setInterval("updateCounter()", 100);

new_cload-call を実行した後に-function でを警告するrefreshCounter()と、空のメッセージが返されることもあれば、ページのコンテンツcounter.php(単なる数字) が返されることもあります。

4

0 に答える 0