javascriptajaxnodemcu

nodeMCU and ajax instead of refresh one element repeats whole web-page


I need help with reloading two elements at my webpage. I have small electronics and its brain is NodeMCU. I need there two outputs (which are connected to relays) and two inputs.

With inputs I want update periodically (without manual reloading webpage) two elements of page according two digital inputs. For that I use ajax. I have found some hints: http://www.martyncurrey.com/esp8266-and-the-arduino-ide-part-8-auto-update-webpage/

Almost everything works perfect (outputs and inputs). Only one problem is that after time out is whole web page repeated and is in web-browser shown twice.

Sorry for adding my code as image (bellow). But when I insert here as a text - may parts of code is recognized as html tag and is not shown. I have placed this code to my webpages: http://fiksoftware.4fan.cz/bojler.ino

Please could anybody give me any advice what is wrong in my code (bellow).

Thanks a lot to all. enter image description here

my code:


Solution

  • I have found solution. My friend helps me!

    problem was in that I have sent whole page after request of data.

    So I have at the begining of creating web page added if which decide if I need data or whole page:

    enter image description here