]> git.gag.com Git - fw/quantimotor/commitdiff
arrange for the page to update itself every second
authorBdale Garbee <bdale@gag.com>
Wed, 7 May 2025 22:54:45 +0000 (16:54 -0600)
committerBdale Garbee <bdale@gag.com>
Wed, 7 May 2025 22:54:45 +0000 (16:54 -0600)
application/index.html

index aaeca09b5494a904258f26e99358d95e7180b37f..598292bea64496f344d49080455c226f6fd4106e 100644 (file)
@@ -5,9 +5,7 @@
 <title>QuantiMotor</title>
 <script type='text/javascript' src='/jquery-3.7.1.js'></script>
 <script type='text/javascript'>
-  $(document).ready(function()
-  {
-    $('button').on('click', function()
+    function updateContent()
     {
       var request = $.ajax({'url': '/getData'});
       request.done(function(response) 
       {
         alert('Request failed: ' + textStatus);
       });
-    })
-  });
+    }
+
+    // update displayed data every second
+    setInterval(updateContent, 1000);
 </script>
 </head>
 <body>
   <h1>QuantiMotor</h1>
-  <button>make ajax call</button>
   <h2>Time</h2>
   <div id='time'></div>
   <h2>Pressure</h2>