Reputation: 153
Here's a piece of code (based on an example at W3Schools) that uses Javascript to update a page on a regular basis:
<!DOCTYPE HTML>
<html>
<head>
<title>Timer test</title>
<script>
var myVar=setInterval(function () {myTimer()}, 1000);
function myTimer() {
var d = new Date();
document.getElementById("timeNow").innerHTML = d.toLocaleTimeString();
}
</script>
</head>
<body>
<h1>The time now is <span id="timeNow"></span></h1>
</body>
</html>
Is there an equivalent in pure Ruby/Rails that would update the "timeNow" span element on a regular schedule?
Upvotes: 1
Views: 896