function getTime() { $.ajax({ url: "/time", timeout: 10000, success: function (data) { $("#tim").html(data); }, error: function (xhr, type, errorThrown) { console.error("Error occurred: ", type, errorThrown); } }); } setInterval(getTime,100)