开发者

setInterval not working for ajax call

I have a getJson call to a webservice and works fine, Now I'm trying to make the request every 10 sec. using setInterval with a callback function to fire an alert pop up. I can't make it work. Here's the code:

function ajxCall(){
   $.getJSON('http://api.tubeupdates.com/?method=get.status&lines=all&return=name,status,messages,status_starts&jsonp=?',
         function (result){
               $.each(result.response.lines, function(i, item){
                    $('#status').append("<p>"+item.name + " - " + item.status + " <br><b>" +item.messages + "</b> " + item.status_starts + "</p>");
               });
         }); 
    }

setInterval(ajxCall(), (10 * 1000), function(){
    alert('called!')
});

What am I doing wrong?

Thanks in advance,

开发者_StackOverflow中文版

Mauro


 setInterval(function() {
      ajxCall();
   }, 10000);

Try that

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜