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
精彩评论