I'm working on an embedded device (ESP32) serving static pages from the internal flash (SPIFFS). I'm looking for a simple way to populate the form values with the actual values since with this approach they are loaded with the default values.
I have a working XMLHttpRequest communication channel. For example I'm able to POST the form values retrieving them with:
document.getElementById("form-controls").onsubmit = function (event) {
event.preventDefault();
fetch("/controls", {
method: 'post',
body: new FormData(document.getElementById("form-controls"))
}).then(function(response) {
});
}
I wondering if there's the opposite function. Using a GET method on the same url I would answer from my MCU with the actual values to be written in the form fields.
I'm able to do this manually using JSON and updating each input tag via javascript.
My question is if there is an equivalent of FormData that given an input data can fill automatically the related form fields.