-
Thank you Gordon, I tried with your changes and it now works as expected. I will try to apply this to my project that involves monitoring and controlling a battery charger. I want to be able to read battery voltage and charge current, display the readings in a table in the web browser and set the charge current and charge voltage remotely. I am using for example the LED1 output to turn the charger on and off. So I was struggling with trying to understand why the webpage would show data that was not updated. I intend to share the code when it is more functional, there may be other people trying to do something similar.
Right - I think I see what's going on...
The flow of execution goes something like this:
handlePOST
finally gets called and updates the state.So actually if you want to receive all the data and then send out the new page, you can use the
end
event inhandlePOST
rather thanclose
.I tweaked the main bit of code to do what I believe you're after here:
(I also send a Content-Length header as it looks like on recent Espruino builds that may be needed to work nicely with Chrome)