• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

ESP32 AsyncWebserver SPIFFS missing HTML elements and styles

Q&A Forum › Category: ESP32 › ESP32 AsyncWebserver SPIFFS missing HTML elements and styles
0 Vote Up Vote Down
Brian Oliver asked 3 years ago

I have modified the AsyncESP32WebServer sketch to load a different HTML (no ref stylesheet, using internal stylesheet).
I have noticed that the rendered HTML and the contents of the <style> tag are missing elements, rendering the resulting HTML page very higgledy-piggledy.
For instance, my style block contains html, body, .heading, .cellHeading, table, tr.odd, tr.even, .footer, however, the page source viewed in the browser only contains html, body, .heading.
Similarly, the HTML contains nested tables, while the page source shows several of these are missing.
I am trying to build a HTML page that allows me to control individual pixels (approx. 125 in total) in a WS2812B strip through the ESP32.
Any thoughts?
Kind Regards
BrianO

Question Tags: Async Web Server, SPIFFS
9 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi Brian.
Did you try opening a file with all your HTML page on your browser, just to check if everything is working as expected with the page?
Are you uploading the file to the ESP32 SPIFFS? Did you change the file name? 
Double-check if you’re not missing any closing tags.
 
Regards.
Sara

0 Vote Up Vote Down
Brian Oliver answered 3 years ago

Hey Sara,
Thanks for the response 😉
I developed the HTML and tested the page in the browser before adding it to my ESP32 project and ran it through the W3C HTML validator and everything was peachy.
No filenames were changed when uploading using the upload tool.
I’ve tried with both inline CSS as well as a link rel to the style.css both with similar results.
Thanks for your help
Kind Regard, BrianO

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi again.
That’s weird.
Are you using placeholders  and the processor() function on your HTML?
Regards,
Sara

0 Vote Up Vote Down
Brian Oliver answered 3 years ago

Thanks Sara,
No, at this stage, the HTML is being served directly, without processing. I tend to work in a “building block” fashion, at this stage, I am using a HTML file with a fair chunk of JavaScript (approx. 22KB) and a style.css file (2KB) reading directly from the SPIFFS /http folder.
The HTML when loaded from the PC into the browser works just fine, and all of the JavaScript works in place too (input type radio and checkbox with onchange event writes into a multi-dimensional array and then writes back to the page using document.getElementById(“field name”).innerHTML = value).
I haven’t got to the stage where the HTML interacts with the sketch and visa-versa.
Kind Regards
BrianO

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi again.
What lines of code are you using to serve the web page when you access the ESP IP address?

0 Vote Up Vote Down
Brian Oliver answered 3 years ago

Hey Sara,
This was lifted directly from the AsyncESP32WebServer.ino sketch:
// Route for root / web page
server.on(“/”, HTTP_GET, [](AsyncWebServerRequest *request){
request->send(SPIFFS, “/index.html”, String(), false, processor);
});
I am going to try to pull the index.html apart to try to identify exactly where it is falling over. I know, that’s probably something that I should have tried when I saw the odd behaviour originally 🙂 First, I’ll try the html without the CSS, then without the JavaScript and then with smaller parts of the nested tables.
I’ll let you know how I get on 😉 unless you see any other problems or have any other suggestions in the meantime.
Thanks for your help!
Kind Regards
BrianO

0 Vote Up Vote Down
Brian Oliver answered 3 years ago

Okay, so I’ve made some progress. It seems that there WAS an issue in the HTML document, the link to the Google fonts directive was incorrect. I’ve removed it and now I have been able to progress.
Now to try to get on with the rest of the coding 🙂
Thanks for your help Sara.
Kind Regards
BrianO

0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Great.
I just want to mention that since you’re not using placeholders on the HTML, you don’t need to use the processor function:

server.on(“/”, HTTP_GET, [](AsyncWebServerRequest *request){
request->send(SPIFFS, “/index.html”, String(), false, processor);
});

Instead, serve the web page as follows:

server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
  request->send(SPIFFS, "/index.html", "text/html");
});

Regards,
Sara

0 Vote Up Vote Down
Brian Oliver answered 3 years ago

Thanks Sara,
I will be using placeholders on the HTML when I am doing some actual processing. Thanks for pointing that out, though 🙂
Kind Regards
BrianO

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.