Вопрос

So I want to update the request to my Github page after an interval. I want to count how many commits I've done to a repo and then in the HTML count the number given from 0. I also want it to update automatically without so the user has to update the page. What happens now is that it gets a request and number and counts, I want the interval to be 10 minutes. As it is now it requests but the counting on the website should start directly not according to the interval after 5 seconds

Это было полезно?

Решение

Ok, thank you LShetty. It worked, heres the complete code:

$(document).ready(function() {
runCode();

    function runCode() {

    var uri = "your url to github";
    var totalCom = 0;
    $.getJSON(uri, function(r) {
        for (var i = 0; i < r[0].total; i++) {
            totalCom = r[0].total;
        }
    //count numbers from zero
    $({countNum:
        $('.row-one-first .number').text()}).animate({countNum: totalCom}, {
            duration: 5000,
            easing:'linear',
            step: function() {
            // What todo on every count
            $('.row-one-first .number').text(Math.floor(this.countNum));
            },
            complete: function() {
            $('.row-one-first .number').text(this.countNum);
            }
        });
    })
}
setInterval (function() {
    runCode();
}, 300000);

});

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top