2014-04-05 1 views
0

간격이 지나면 Github 페이지로 요청을 업데이트하고 싶습니다. repo에 대해 수행 한 커밋 수를 계산하고 HTML에서 0부터 주어진 수를 계산합니다. 사용자가 페이지를 업데이트하지 않아도 자동으로 업데이트되기를 원합니다. 지금 요청이 발생하고 숫자와 카운트가 발생하며 간격을 10 분으로 설정합니다. 지금은 요청하지만 웹 사이트에서의 계산은 5 초 후에 간격에 따라 직접 시작하지 말아야합니다.간격 후 api에서 업데이트 번호

+0

코드 게시하시기 바랍니다. – lshettyl

+0

http://jsfiddle.net/95pfB/ – Chilibiff

+0

간격을 10 분으로 설정 하시겠습니까? 5 초? 혼란스러워! – lshettyl

답변

0

Ok, 감사합니다. 이 코드는 다음과 같이 작동합니다.

$(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); 

});

관련 문제