英文:
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 to update periodically (without manual reloading the webpage) two elements of the page according to 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 perfectly (outputs and inputs). Only one problem is that after a timeout, the whole webpage is repeated and is shown twice in the web browser.
Sorry for adding my code as an image (below). But when I insert it here as text, many parts of the code are recognized as HTML tags and are not shown.
I have placed this code on my webpage: http://fiksoftware.4fan.cz/bojler.ino
Could anybody please give me any advice on what is wrong with my code (below).
Thanks a lot to all.
英文:
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).
my code:
答案1
得分: 0
我找到了解决方案。我的朋友帮助了我!
问题出在我在请求数据后发送整个页面。
所以在创建网页的开头,我添加了一个条件来决定是否需要数据还是整个页面:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论