Auto Reload Local ESP8266 Web Server

How to auto-reload my local ESP8266 Web Server every 1 second? For now I can only refresh manually to view the real live data.

Find a HTML tutorial.

Your post was MOVED to its current location as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.

It will help you get the best out of the forum in the future.

In HTML i add
<meta http-equiv=refresh content=2>
and the browser auto reload page every 2 secs.

// setup()
server.on("/", []() { 
     server.send(200, "text/html", index_html); 
});

  server.on("/data", []() {
    String dataJson = "{ \"name\": \"" + my_name + "\" , \"age\" : " + String(age) + "}";
    server.send(200, "application/json", dataJson ); 
});

// loop()
server.handleClient();


// Javascript
async function UpdateDoc() {
    await fetch('/data', {
        method: 'GET',
      }, 5000)
      .then(async r => await r.json())
      .then(async d => {
        const dt = d;
        console.log(dt)
      })
  }

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.