const viewsCount = document.getElementById("views-count"); const viewsLoader = document.getElementById("views-loader"); viewsCount.style.display = "none"; viewsLoader.style.display = "inline-block" ajax(serviceUrl + "/GetPostViews?siteId=" + siteId + "&postId=" + postId) .then(function (result) { viewsCount.innerText = result; viewsLoader.style.display = "none"; viewsCount.style.display = "inline-block"; }) .catch(function () { viewsLoader.style.display = "none"; viewsCount.style.display = "inline-block"; });