ngth; i++) { var item = results[i]; var url = item.url; var time = item.time; var element = document.getElementById(url); $(element).find(COUNT_CONTAINER_REF).text(time); } for(var i = 0; i < entries.length; i++) { var url = entries[i]; var element = document.getElementById(url); var countSpan = $(element).find(COUNT_CONTAINER_REF); if( countSpan.text() == '') { countSpan.text(0); } } }) .fail(function ({ responseJSON }) { console.log("LeanCloud Counter Error: " + responseJSON.code + " " + responseJSON.error); }); } $(function() { $.get('https://app-router.leancloud.cn/2/route?appId=' + "bQj0duOu4duPTzRWh3nmNqNG-gzGzoHsz") .done(function ({ api_server }) { var Counter = function (method, url, data) { return $.ajax({ method: method, url: `https://${api_server}/1.1${url}`, headers: { 'X-LC-Id': "bQj0duOu4duPTzRWh3nmNqNG-gzGzoHsz", 'X-LC-Key': "8RVBaAkuHUkExbSP4g6iSYcf", 'Content-Type': 'application/json', }, data: data, }); }; if ($('.post-title-link').length >= 1) { showTime(Counter); } }) });