setInterval(getLatestData,6000); function getLatestData() { var url = ctx + "platform/activity/getLatestData"; $.ajax({ type: 'post', data: {'activityId': activityId }, dataType: 'json', url: url, success: function(data){ console.log(data); $("#viewNum").text(data.viewNum); } }); }